Typo3: Using Page Alias And Other Page Record Fields in TMENU Menus
Problem: Your web site uses the Typo3 CMS. Your typoscript templates contains TMENU objects for navigation menus. You want to use the page alias somewhere in the A
tags of these TMENU menus. For example, you want to set the id of a menu item's A tag to the alias field of the page that the menu item stands for.
<a id="widgets" href="...">Buy Widgets</a>
Buy Widgets
is the title of the page and widgets
is its alias.
Solution: Use the following TypoScript in your template:
temp.menu.1 = TMENU temp.menu.1 { NO.ATagParams = id="{field:alias}" NO.allStdWrap.insertData = 1 }
Explanation: NO.allStdWrap.insertData = 1
makes Typo3 replace text in curly brackets {}
with the value of page record fields. Hence, {field:alias}
is replaced by the alias of the current menu item's target page.
Why this article? I had the above problem but I only found more complex solutions that didn't appeal to me because they hardcode the A tag. I like the Typo3 generated A tag because it contains a nifty JavaScript snippet that prevents the ugly dotted rectangle being drawn around the link when it's foucsed (blurLink
). subst_elementUid
is a similar typoscript hack but it uses the numeric uid instead of the alias. Besides, the solution described here is more versatile.