The aim is:
- to have a menu entry for some groups
- to control the order of these entries
- to have a nice (and eventually multi-lang.) title
First: a HomePage for each group
Each group must define a page named HomePage (you can call it Foo if you want). This page is the page linked with the left menu entry. It must contain:
(:MenuOrderVariable: order) (:title Text for the menu entry:)
The value of MenuOrderVariable is used to sort the left menu that is if you use a value like AAAA this group will appear at the begining of the left menu and value ZZZZ will push the group at the bottom of the menu.
The title is the text that will be used for the entry.
Second: edit the SideBar
Edit the Site.SideBar page and put these lines:
(:pagelist name=HomePage $:MenuOrderVariable=- fmt=title order=$:MenuOrderVariable :)
Here we list all page named "HomePage" that defines the MenuOrderVariable. We sort these page alphabetically regarding to the value of MenuOrderVariable. Finally, we use the title of each page for the entry name.
Third: multi-language support
You can have the multi-language support by using the MultiLanguage recipe.
Then, for each HomePage you can add a translation for the title as follow:
(:MenuOrderVariable: AAAA:) (:if userlang fr:) (:title Titre de page:) (:if userlang en:) (:title Page title:) (:else:) (:title Default Title:) (:ifend:)
The problem is that the multi-language recipe change the userlang depending on the language available in the current page: that is, if the user set his language to fr but the current page use the en value, then the userlang will fall to en and the menu will be printed in en too!
For my personnal used, I patch the multilanguage.php as follow (line 75):
if ($EnableDefaultLanguage){
$PageLanguages = explode(',',$PCache[$pagename]['languages']);
if (!in_array($userlang,$PageLanguages)) {
.....
}
}
$Conditions['userlang'] = '$GLOBALS[\'userlang\']==$condparm';
and I set the $EnableDefaultLanguage to FALSE in my configuation file before including the recipe.
Comment
- Why using a fixed page name (i.e. HomePage)? using a fixed page name increase the speed for the pagelist command.
- My page title is too long, I would like to use a short title for the menu entry:
take a look to Pagelist Template. Edit the page Site.PageListTemplates and add your own fmt using a personnal PageVariable (menu_title for example).