[TYPO3] can I modify ALL <a href-Tags (i.e. add class attribute)?

Christopher bedlamhotel at gmail.com
Sat Jan 21 20:11:08 CET 2006


Hi,

On 1/21/06, Claus Faber <claus.faber at attac.at> wrote:
> Hi, this may be a newbie question, but I didn't find it anywhere:
>
> Can I modify all links that are rendered by typoscript in one go?
>
> 1) adding a wrap to include a class attribute?
> 2) including a TITLE tag for mouseover (where do I get the title of a
> page from?)
>
> If not, what is the way to access the different objects? Do I have to
> get them one after the other (all tt_content objects, rtehtmlarea;
> HMENU and the like)?
>
> many thanks,
>

Short answer: yes.

Long answer:

Virtually any HTML output by TYPO3 is based on TS. In the case of
links, this means the TS typolink object/function [1]. If you really
did want to add something by default to _every_ link created with the
RTE, you could add something like this:

lib.parseFunc_RTE.tags.link.typolink.ATagParams = class="lorem"

...to your main TS template. This would also work with e.g.
'title="Ipsum dolor"'.

Some comments though:

-- adding a class to ALL links (or ALL of any element) just
unnecessarily bloats the markup. There's never any good reason to use
a class to define the DEFAULT state of an element; just define the
element itself instead. So don't use:

a.defaultLink { /* Properties */ }

...but do use:

a { /* Properties */ }

...if you need links to appear differently, depending on where they
are located on the page/site, do this:

/* Styles links inside <div id="foo"> or <body id="foo"> */
#foo a { /* Properties */ }

/* Styles links inside <div id="bar"> or <body id="bar"> */
#bar a { /* Properties */ }

About 99% of the time, the only reason I find to use a class on links
is to indicate the active link in a navigation menu (e.g. something
like <a href="/foo/bar/" class="activeLink">Bar</a>).


-- the typolink property 'ATagParams' is not a stdWrap property, so
you can't use it to get information such as the page title. I can't
really understand why you'd want a _default_ title any more than I can
understand why you'd want a default class on an element.

You can add titles to each link in the RTE as it's created, and you
can, build your menu objects so that they reflect the page title
(since there is a convenient 'ATagTitle' property for TMENU items
[2]).


-Christopher


[1] http://typo3.org/documentation/document-library/doc_core_tsref/typolink/
[2] http://typo3.org/documentation/document-library/doc_core_tsref/TMENUITEM/



More information about the TYPO3-english mailing list