I haven’t yet figured out everything about the WayFinder and at this point am completely confused by the documentation about how template chunks work with it but am anxious to fully understand it (and then perhaps write something up about it as I’ve written several training manuals that people have found helpful.)
At any rate I’ve modified this Snippet here:
Original Code:
// get languages info
$tv = $modx->getTemplateVar('languages', "", $modx->documentIdentifier);
$languages = $tv['value'];
Modified To:
// get languages info
$tv = $modx->getTemplateVar('LanguagesEN', "", $modx->documentIdentifier);
$languages = $tv['value'];
I’ve created a LanguagesEN snippet to handle the English page redirects and a LanguagesFR to handle the French redirects. I’ve also created two snippets, LanguageSwitchEnglish and LanguageSwitchFrench which are place with the anchor element of the language menu which is why I had to change the code below in the original snippet:
Original Code:
// seperate into lang code and target document id
list($lang, $targetid) = explode("=", $entries[$e]);
$image = '<img src="assets/images/'.$lang.'.gif" width="16" height="11" border="0" alt="'.$langnames[$lang].'" />';
if (strlen($output))
{
$output .= ' ';
}
$output .= '<a href="'.$modx->makeUrl($targetid).'">'.$image.'</a>';
}
return $output;
Modified To:
// seperate into lang code and target document id
list($lang, $targetid) = explode("=", $entries[$e]);
if (strlen($output))
{
$output .= ' ';
}
$output .= $modx->makeUrl($targetid);
}
return $output;
Now, I’ve created two Template Variables, LanguagesEN and LanguagesFR. Ideally, I’d like to associate the EN TV with the English Template and the FR TV with the French, rather than including them in both. However, I’m not sure how to program the Snippets to go the current page if the value of the TV is empty. If I could do that, then I wouldn’t have to place both TVs in both templates and set them both (I will make a generic en=x / fr=x page to go to if there is no translation.) From what I can gather this line:
Is the result if it is empty and it is in there that I should be able to designate that the link (when empty) goes to the current document.