plainblack.com
Username Password
search
Bookmark and Share

LanguagePageSwitch

Main purpose is to be able to switch between similar pages with the same content with different languages. Other purposes can off course also be used.

This macro generates links to pages that relative have the same rank in respect to a given root page. This is done by lineage, so the order in which the pages are added is of importance. You will get the wrong pages if you change rank in one page or if there is an extra page in one language page tree, the next page will have a higher rank than his brother in the other page tree.

The macro takes key-value pairs as arguments, in which the key is a label for showing the link and the value the url of the page tree root asset.

Example:
^LanguagePageSwitch(Dutch,"/home/nl",English,"/home/en");

When a page with the macro is not in such a page tree, or when the root url does not exist, that is logged at error level.

When an asset has not a "brother" page, the link url will be that of the page root and at warn level an error is logged.

I have thought of an extra parameter where you can modify the lineage for in the script itself, but have not done so. The reason is that it was meant to be able to use it in a template on the whole page tree. So a correction in lineage is a solution that will not work properly.

Author: BartJol

Release Notes for Version 2 (8/21/2009)

Added comments in code and made use of some variables local in a foreach loop instead of global within the macro

Comments
4bartjol: "Oh, and I don't want any money for it, but a small amount of karma is appreciated ;)"
0bartjol: "oh, if you use it in a site wide template of which the language page trees do not cover all assets, it  can be that the error log will be quite full with errors. The macro just returns nothing is this case, and the errorHandler level on line 69 might better be set to warn."
DownloadLanguagePageSwitch.pm LanguagePageSwitch.pm
LinksNo Support Offered
Statistics Downloads: 593
Views: 2498
Rating: 4
Updated: 8/21/2009
Keywords language macro macros pagetree switch
NavigationMore from BartJol
Back to the Bazaar
© 2018 Plain Black Corporation | All Rights Reserved