Add CSS class to external links
Posted: 21 May 2006 04:35 PM   [ Ignore ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  1522
Joined  06-20-2005

Hi,

I wanted a way of designating external links, either with a graphic or a different colour, because this can be an important feature of usable/accessible websites.

If your clients use Textile (like mine) or a WYSIWYG editor then you may not be able to ensure that they apply an appropriate class to such links (until attribute selectors are widely supported). This plugin enables you to do that.

Wrap {exp:external_links} around text you wish to process. There are two parameters:

class=“the CSS class you wish assigned to external links” (will default to ‘external-link’ if you don’t specify a class)

local=“the site domain name”

So, assuming your domain is ‘myblog.com’ then this:

{exp:external_links class="external" local="myblog.com"}
<p>Lorem ipsum dolor sit amet, <a href="http://www.anotherblog.com">consectetuer</a> adipiscing elit. Aenean eros ipsum, egestas non, <a href="http://www.myblog.com/gallery/">hendrerit</a> a, sollicitudin non, magna. Duis lacinia massa.</p>
{/exp:external_links}

will output this:

<p>Lorem ipsum dolor sit amet, <a href="http://www.anotherblog.com" class="external">consectetuer</a> adipiscing elit. Aenean eros ipsum, egestas non, <a href="http://www.myblog.com/gallery/">hendrerit</a> a, sollicitudin non, magna. Duis lacinia massa.</p>

It is will take href attributes like ‘title’ into account and place the class at the end of them.

NB: This doesn’t yet work properly with external links that have query strings.

I hope someone else finds this useful.

Cheers

Dry

File Attachments
pi.external_links.txt  (File Size: 4KB - Downloads: 391)
 Signature 

   Purple Dogfish | Member of EE Pro Network | Follow me on Twitter

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120427 Total Logged-in Users: 60
Total Topics: 126522 Total Anonymous Users: 34
Total Replies: 665284 Total Guests: 328
Total Posts: 791806    
Members ( View Memberlist )