Thanks for the swift answer AHHP, I finally got it.
So to be able to use Wayfinder (don’t know Ditto yet) I will have to use the config method Shane pointed out:
Also a smart way to use this function is to have multiple config files with the lan prefix then simply use
Code:
[[Wayfinder? &config="[%LANG%]config`]]
The method to handle language switching in Wayfinder menus is all there, albeit in one compact sentence.
For the benefit of any fellow newbies as slow as myself I will walk it:
- Follow AHHP:s instructions of the first post to the letter.
At 4. Save it. Create necessary TVs, Chunks and Snippets. Put plugin valid tags in Templates, Document content and Document introtext.
create a TV with variable name: depagetitle (input type Text). Under Template Access, check the Template you’re using.
- Go to the pages you want to show in the Wayfinder menu and, in the field depagetitle, add the desired german equivalents to your documents pagetitles, e.g. Wir über uns, for an "About us" page.
[li]Create a plain text file with the following content:
<?php
/* This config file is used by EasyLingual; has to reside in this configs folder; is called by Wayfinder with [!Wayfinder? &config=`[%LANG%]config`!] from desired template. It holds the parameters for an output of TV-values (i.e. fieldvalues) from e.g. depagetitle (=German pagetitle). The config file prefix will tell what language. Added by [yourself] */
$rowTpl = '@CODE:<li[+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+depagetitle+]</a>[+wf.wrapper+]</li>';
?>
Obviously, skip the excessive comment if you find it stupid or kludgy, or at least delete it in production. I don’t know if it affects performance, I don’t know php...
[list]- Save it as "deconfig.config.php" in /assets/snippets/wayfinder/configs/ where the preinstalled (MODx 0.9.6.3 at least) Wayfinder config files reside.
- Go to edit your Template. Add [!Wayfinder? &config=`[%LANG%]config`!] where you want the menu to be output.
- Go to your front-end. Switch language to German, the menutitles should now be in German. (see first post for how to add links to switch with).
- As you can see the depagetitle value was hardcoded in the config file, whereas in a Template you would be able to use [*[%lang%]pagetitle*]. The switching to German is instead taken care of by placing a [!Wayfinder? &config=`[%LANG%]config`!] call in the template which will look up the right config file for that language
- To sum up: Switching language with EasyLingual is straightforward, just create a desired TV e.g depagetitle and insert [*[%lang%]pagetitle*] in templates and content. If you want to use Wayfinder however, you would have to add one configfile per language where the two first letters of the config filename is addressed by the [%LANG%] part. In this configfile you put the full name of the TV, e.g. depagetitle.
- Note that the placeholder syntax for default document variables differs from placeholders for TV:s. If you haven’t created a enpagetitle TV, and are using the standard document pagetitle field for the english title (assuming english is your default language) you would use
[+wf.pagetitle+] [+wf.title+] (sic!) where the german configfile has [+depagetitle+]. For consistency you might be better off creating TV:s for your default language as well.
Obviously, this is a basic illustration of WF+EasyLingual menus. It could propably be far less messy in production, e.g. by calling the additional config parameters common to all languages separated from lang-specific ones and avoid redundant startID:s etc. I haven’t had time to examine how, though.
For a tutorial on Wayfinder I’d recommend
http://modxcms.com/forums/index.php/topic,34176.0.html
I will gladly edit or delete this post should you find errors. I have just started to examine MODx, and in that process I have been much helped by detailed instructions, admittedly far better written than my first try above. This is how I understood it.
[/list]