Add CSS class to external links
Posted: 21 May 2006 04:35 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  269
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: 194)
 Signature 

   Purple Dogfish | Member of EE Pro Network

Profile
 
 
   
 
 
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 1149, on July 16, 2007 10:33 AM
Total Registered Members: 60711 Total Logged-in Users: 19
Total Topics: 73164 Total Anonymous Users: 9
Total Replies: 394606 Total Guests: 533
Total Posts: 467770    
Members ( View Memberlist )