Blog
7SepTYPO3 Concept: Backend Localization Filter
Posted on September 7, 2010 in Extension Development,Extensions byWe all know TYPO3 supports multiple languages in as well the frontend as the backend. But this flexibility is for some major corporate websites not enough. Recently I had to deal with one that had 43 different localizations.
There were several other small points of interest as well though. 43 Localizations is not the same as 43 different languages. In fact, there were only 6 different languages. They were just spread over 43 regions. Of which the content could actually be the same, or different.
The Approach
Instead of setting up 43 page trees, I decided to take a different approach. I decided just to take use of TYPO3s' built-in support for languages. Now with 2 maybe 3 languages, this would give no problem at all of course. But imagine seeing each record 43 times on a single page?
So I decided to built a 'little' tool, to help us solve this problem. I called it the 'Localization Filter'. The idea is, to specify at any time, which content from which languages should be displayed. So editors could easily switch between languages without much fuss.
In my case this was especially useful, because like I said before, there are only 6 real languages involved. Otherwise a construction with different backend users having only access to specific languages would have been an option as well.
The Result
The result of what I had in mind and actually created was actually quite cool (if I say so myself). Switching between languages can be done as shown below.
![]()
Since the icon is displayed at the top bar, it can be accessed from anywhere inside the TYPO3 backend.

Once a selection is made, it's stored in the backend users' session. The list view and page tree are automatically refreshed. So no further action is required to display the proper content.
Some nice little extras
Too make things clearer to the user/editor, I've built in some nice flash messages as well. To show the user when and what languages are filtered out.
Next to that there is an option to apply the filter on the page tree as well. This has a built-in check that will make pages gray if and when a page is not translated in any of the selected languages (checks the page language overlay).

Limitations
Of course I've built this tool the way I thought it should be. The following features are not yet supported.
- Web > Page
- Templavoila
How to achieve?
If you think I had to hack my way into the TYPO3 core to achieve this you are wrong. By using some of the hooks found inside the TYPO3 core and some clever tricks I was able to quite easily build this.
The most time consuming was however figuring out how some of the core and backend parts of TYPO3 work. By reverse engineering certain processes I found several hooks I could use to make my filter behave like it should.
The Hooks
In total I used just 4 hooks, to achieve this. These are the ones I used, and what I used them for.
Adding an addition backend item 
- $GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems']
$GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems']
Add an additional toolbar item, this is the flag in the right top that triggers the filter dialog.
Adding additional JavaScript and CSS 
- $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook']
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook']
I used this hook to add an additional JavaScript/ExtJS file that is used to render the filter dialog. I also included a small extra CSS file with this.
Altering the list query 
- $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray']
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray']
This hook I used for altering the query that displays the records in Web > List. This is where the actual filtering is done.
Modifying the page tree 
- $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay']
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay']
For altering the page tree, I have used the following hook.
Using some clever tricks
Now if you ever use any of these hooks to achieve something like I did, you will find out you will not always get what you are looking for. Most of these hooks are either called more than once, or on pages where you don't want your action to take place. To bypass this, you will need to filter out these requests.
Another problem I encountered was including the JavaScript library at the right position. I always ended up with the script being loaded, later then it should be. In order to solve this problem I needed to access the t3lib_PageRenderer. The only problem was that this object was protected. I had no access to it.
I could bypass this by making a new instance of it inside my function. Since t3lib_PageRenderer is a singleton class, it could only be loaded once. So by calling the following:
Creating a new instance of the PageRenderer 
- $o_pageRenderer = t3lib_div::makeInstance('t3lib_PageRenderer');
$o_pageRenderer = t3lib_div::makeInstance('t3lib_PageRenderer');
I was still able to access the otherwise 'inaccessible' object.
Conclusion
It took me quite a while to find out what I needed for my extension. This also means it took quite some time to build it. But in the end, I made myself better out of it by understanding better how the TYPO3 backend works.
Another thing this proves is that it shows just how flexible TYPO3 actually is. I was able to make all these changes, without changing anything in the TYPO3 core.
The Extension
The extension is currently private, I have not chosen to share or publish it (yet). However if people are interested in it, or would like to further develop it, I will be happy to share it in the TYPO3 forge. So if people are interested, please let me know.



at 06:14
A "should have" feature in TYPO3
This can make it so more userfriendly for websites with multi language..
I see the potential! The TYPO3 backend can improve in ways like this.
Keep up the good work!
at 07:50
Nice work
Cool you got it working.
at 10:46
great idea
I'd probably move the setting to the user settings though, I guess they won't change every day...
at 10:16
RE: great idea
That would prevent users from changing it themselves. It would also make the interface less easy to use, since you would have to go to the user settings every time you would like to display something else..
at 14:36
Sharing?
Can you share it on forge or send me a copy? I tried fb_hybridmultilanguagetree but thats not working anymore.