-
- 805 Posts
With YAMS, whether or not to resolve weblinks with Wayfinder is controlled by which YAMS templates you use. The templates in the doc folder don’t resolve weblinks. Eg:
@FILE:assets/modules/yams/tpl/wayfinder/doc/row.tpl
The templates in the docr folder do. Eg:
@FILE:assets/modules/yams/tpl/wayfinder/docr/row.tpl
So, you don’t need to use the &useWeblinkUrl parameter.
-
- 805 Posts
I’m pretty sure I know what’s going wrong for you... Your weblink is probably associated with a multilingual template. You are specifying the link in the standard document variable ’weblink’ field, leaving the multilingual content fields blank. Is that right?
If your weblink is associated with a multilingual template, then it too is multilingual. That means that you have to specify the weblink (document number or web address) in each of the multilingual content fields. (Make sure that the RTE option is switched off.) The document variable weblink field is redundant in that case. This set-up means that each language can be linked to a different page if you wish.
Alternatively, you could associate your weblink with a monolingual template and use it like you would normally. Provided you are using the docr Wayfinder templates you should get the result you expect. [+wflink+] in not required.
Let me know if that helps.
-
- 1,024 Posts
Ho Pm,
could you give me an example, cause I really have no idea what is should fill in in those fields.
You are right, it is using a multi linguale template,
Fr.
-
- 805 Posts
Ah ha...
First make sure that the RTE setting is set to off for the document. Save it to apply the change if necessary. Then...
If you want your weblink to point to a MODx document, then type the id of the document you want to link to into each of the multilingual content fields.
If you want your weblink to point to an external webpage, then type the address of that webpage into each of the multilingual content fields.
That should be it.
Thanks for the instructions posted here. I have followed them through, but have one issue: my English weblink is resolved, but when I switch into Turkish the weblink points to the website homepage. I have put the same document ID in the content field of both languages, turned off the RTE etc. Any suggestions for what is wrong?
I am doing this to get round FirstChildRedirect not working, and is using 1.2.0RC3.
-
- 7 Posts
@PeterBowyer
Hi there. I was just wondering whether you’ve managed to resolve the weblink issue you described above and, if so, how?
I am having the exact same problem myself, have also followed PM’s instructions to the letter, but still get redirected to the home page once I change language.
Thanks.
Regards,
Les@ITworks
Les, I didn’t get it to work, so instead I created a modified version of FirstChildRedirect. This’ll only work if your language is at the site root (e.g.
http://example.com/fr/pagename.
YAMSFirstChildRedirect:
<?php
/*
* @name FirstChildRedirect
* @author Jason Coward <[email protected]>
* @modified-by Ryan Thrash <[email protected]>
* @license Public Domain
* @version 1.0
*
* This snippet redirects to the first child document of a folder in which this
* snippet is included within the content (e.g. [!FirstChildRedirect!]). This
* allows MODx folders to emulate the behavior of real folders since MODx
* usually treats folders as actual documents with their own content.
*
* Modified to make Doc ID a required parameter... now defaults to the current
* Page/Folder you call the snippet from.
*
* Modified to work with YAMS
*
* &docid=`12`
* Use the docid parameter to have this snippet redirect to the
* first child document of the specified document.
*/
$docid = (isset($docid))? $docid: $modx->documentIdentifier;
$children= $modx->getActiveChildren($docid, 'menuindex', 'ASC');
if (!$children === false) {
$firstChild= $children[0];
$firstChildUrl= $modx->makeUrl($firstChild['id']);
} else {
$firstChildUrl= $modx->makeUrl($modx->config['site_start']);
}
$lang = $modx->runSnippet('CurrentLanguage');
return $modx->sendRedirect('/'.$lang.$firstChildUrl);
?>
You’ll also need this snippet called CurrentLanguage:
<?php
require_once( $modx->config['base_path'] . 'assets/modules/yams/class/yams.class.inc.php' );
// Get an instance of the yams class
/* @var $yams YAMS */
$yams = YAMS::GetInstance();
if ($yams->IsMultilingualDocument($modx->documentIdentifier)) {
$lang = $yams->GetCurrentLangId();
} else {
$lang = 'en';
}
return $lang;
?>