Typo3: Different CSS styles for internal and external links

Submitted by Hannes Schmidt on Mon, 12/27/2004 - 08:14.

It's often considered convenient to decorate external links in order to indicate the distinction between links that go to a page on the same site and links that leave the site. On one of my sites I use CSS to set a background bitmap for all links. Until today the bitmap was the same for internal as for external links. I used a little hack in order to set the class attribute of internal links to some value while leaving external links untouched.

Add the following line to the constants field of your root template:

styles.content.links.target = _self" class="int-link

This looks a bit strange at first. How does it work? When it finds links in content objects, Typo3 generates a <A> tag. The target attribute of this tag is set to whatever the value of styles.content.links.target is. Also, double quotes are added before and after this value. In our case the inserted value is _self" class="int-link. With quotes this becomes "_self" class="int-link". The complete A-tag that is sent to the browser is:

<A target="_self" class="int-link">

Due to our little hack, the class attribute piggy-packs on the target attribute. For Typo3 it's still only one target attribute whereas to the browser it appears as two separate tags because of the space between them. The core of the hack is this: With target attributes, Typo3 distinguishes between internal and external links. There is two constants, styles.content.links.target for internal links and styles.content.links.extTarget for external ones. Because we didn't do anything to styles.content.links.extTarget, external links will not have a class attribute.

Use the int-link class in your CSS style sheets to give internal links a different visual appearence. For example,

#content A { color:red }
#content A.int-link { color:green }
( categories: Typo3 | Webmaster )
Submitted by Hannes Schmidt on Wed, 03/09/2005 - 02:31.

Works for me. Have a look at this page. It has internal and external links. What is your Typo3 version?

Submitted by Anonymous (not verified) on Tue, 03/08/2005 - 07:24.

Seriously, Typo3 chenges the quotes to the HTML encoded version, you fix does NOT work. I have tried it for a full day of work and nothing!

Submitted by Anonymous (not verified) on Mon, 03/07/2005 - 10:42.

Why is the code displaying & quot; Vs. a quote ?