[Typo3-dev] Language menu using typoscript+HMENU instead of custom PHP code
Hannes Schmidt
mail at hannesschmidt.de
Thu Apr 29 18:15:29 CEST 2004
Hi,
One of my clients' typo3 sites is multilingual. For that matter, I was
adapting sample_languageMenu.php to my site while I noticed that a language
menu is very much like the HMENU content object. I thought it should be easy
to implement a language menu using HMENU and typoscript instead of custom
PHP code. That way I wouldn't have to reinvent the wheel regarding
image-preloading (mouse-overs) and link generation (simulate_static_docs).
However there is a minor glitch that currently prevents me from doing this.
I think this glitch is easy to fix for someone who knows typo3 internals
better that me.
This is my approach:
includeLibs.languageMenu = fileadmin/ts/languageMenu.php
t.languageMenu = HMENU
t.languageMenu.special = userfunction
t.languageMenu.special.userFunc = user_languageMenu_class->languageMenuRows
t.languageMenu.1 = GMENU
t.languageMenu.1.NO = 1
The PHP function user_languageMenu_class->languageMenuRows() simply queries
the database tables 'pages', 'pages_language_overlay' and 'sys_language' and
returns the default page record and the alternative page language records of
the current page. The returned rows contain the fields from table 'pages'
(as specified) *as well as* the fields from table 'pages_language_overlay'.
This means that we can use these additional fields to tweak the menu items.
The GMENU uses an itemArrayProcFunc to override the item state to ACT for
the menu item representing the current page language according to
sys_language_uid.
So far everything works fine but:
Every URL in the menu contains the parameter L=<uid> where uid is the <uid>
of the *current* page language (due to config.linkVars = L). It should be
the uid of the target page's language! There is no way to remove the
parameter and there seems to be no way to add a parameter based on fields in
the page record representing the menu item. The only way the generated URL
can be changed is 'addParams'. But 'addParams' can only append a static
string to the generated URL. What we need is a way to *change* the L
parameter from the uid of the current page into the uid of the target page.
More information about the TYPO3-dev
mailing list