We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 349
    • 76 Posts
    Please post your chunk faqtpl too. What are you writing to produce the link?
      • 17010
      • 20 Posts
      Certainly. faqtpl is:
      <a href="[~[+id+]~]">[+title+]</a> [+description+]

      This is what produces the link.
        • 17010
        • 20 Posts
        Ah yes.... appending [(base_url)] to the link resolves it. Apologies for the noise.
          • 8464
          • 2 Posts
          hello, great job for this tuto, just the tv languageid is a pain for huge site so replace the snippet [[link_to_language]] by that (with the same name and delete this tv):

          <?php
          if(! function_exists('getPagesWithSameAliasAndDifferentLanguageThanCurrentPage')){
          	function getPagesWithSameAliasAndDifferentLanguageThanCurrentPage($currentPageArray){
          		
          		global $modx;
          		$ids = array ();
          				
          		// get childrens from other ultimate parents which have the same alias
          		$table = $modx->getFullTableName('site_content');
          		$result = $modx->db->select("id", $table, 'alias="'.$currentPageArray['alias'].'"'.' and id != "'.$currentPageArray['id'].'"'); 
          		$array_result = $modx->db->makeArray($result); 
          		foreach ($array_result as $value) { 
          			$ids[] = $value['id']; 
          		}
          		return $ids;
          	}
          }
          	
          $theURL = $modx->makeURL($modx->documentIdentifier,'','','full');
          
          // folder language
          $langFolder = $modx->getDocumentObject('id', $id);
          $langFolderID = $langFolder['id'];
          $langFolderAlias = $langFolder['alias'];
          
          // language = Ultimate parent language folder id
          $currentLanguage = $modx->runSnippet('UltimateParent', array('id' => $modx->documentIdentifier));
          
          // current page infos
          $currentPage = $modx->getDocumentObject('id', $modx->documentIdentifier);
          $currentId = $currentPage['id'];
          $currentAlias = $currentPage['alias'];
          
          // if the current page is in another language
          if($langFolderID != $currentLanguage) {
          	
          	// get page ids in other languages
          	$pages = getPagesWithSameAliasAndDifferentLanguageThanCurrentPage($currentPage);
          	
          	foreach ($pages as $page){
          		$UltimateParent = $modx->runSnippet('UltimateParent', array('id' => $page));
          		if($langFolderID == $UltimateParent){
          			$theURL = $modx->makeURL($page,'','','full');
          			break;
          		}
          	}
          }
          
          return $theURL;
          ?>
          
            • 349
            • 76 Posts
            Hi edgeunter,

            your script does the same, as mine already does. If you want the use the alias instead of the languageIdentifier field you just have to replace the function call
            $pages = getdocs_with_same_values('default','languageIdentifier');

            with
            $pages = getdocs_with_same_values('default','alias');

            in the snippet link_to_language.

            That´s all. But it´s not good the use the alias because you eliminate user- and search-friendly URLs.
            Normally you also translate your aliases to the actual language so that it is still readable for foreigners.

            Greetz
            Aceman3000
              • 8464
              • 2 Posts
              yes, this script is based on yours and does the same exept that you don’t have to add the languageIdentifier and you save the time to change it for each page. For exemple i’m working on a site with hundreds pages and the customers don’t want to make this job when they add a language to their site. The Idee is to use the title of the ultimate parent as your Languageidentifier ,exept that it is the same and it was make to be use as yours, but I think it’s a step to improve the modx i18n functionnality.
                • 349
                • 76 Posts
                Hi edgeunter,

                you don´t need to add the template variable "languageIdentifier" if you don´t want to.
                You can use the code i posted before your reply to use the alias field or any other field like description.

                So you only have to enter an alias on the page, and there you go.

                Also note that if you duplicate your first language folder where languageIdentifier is set it gets also duplicated and your customers don´t need to do anything.
                  • 27437
                  • 49 Posts
                  I have a silly problem...

                  I did the tutorial which works great, now i want to divide my menu in 3

                  my modx site
                  |->NL
                     |->thuis
                         |->welkom
                     |->contact
                         |->map
                  |->EN
                     |->home
                         |->welcome
                     |->contact
                         |->map
                  |->DE
                     |->zu hause
                         |->wilkommen
                     |->contact
                         |->map

                  so i use three different lists based on this tree.

                  something like this
                  +--------------------------------------------+
                  | home | contact                                             NL | DE | EN |
                  +--------------------------------------------+
                  | welcome |                                                                         |
                  |               |                       content                                      |
                  |               |                                                                         |
                  +--------------------------------------------+

                  the first 2 comes with the tutorial:
                  <div id="languageselection">
                  [[LanguageChooser]]
                  </div>
                  <div id="navigation">
                  [!Wayfinder?&startId=`[+LanguageID+]`&level=`1`!]
                  </div>


                  the third i made myself by trying a lot and in the end i came up with:
                  <!-- return ID on page so i can check it -->
                  [!UltimateParent?&id=`[*id*]`&top=`[+LanguageID+]`!]
                  <!-- jay this code works -->
                  [!Wayfinder?&startId=`[!UltimateParent?&id=`[*id*]`&top=`[+LanguageID+]`!]`&level=`1`&outerClass=`nav`&innerClass=`subnav`!]


                  But when i delete
                  <!-- return ID on page so i can check it -->
                  [!UltimateParent?&id=`[*id*]`&top=`[+LanguageID+]`!]


                  my 3th list gives an error:
                  `&level=`1`&outerClass=`nav`&innerClass=`subnav`]]


                  I have been told that for starter [! [! !] !] cant work..
                  i also tried [[ [! !] ]] and [! [[ ]] !]
                  without succes


                  so i hope someone can help me out with this one

                  in the pic my 3 menu’s are working as they shoul (for now), but i can’t delete the code that give’s the id-number (99)

                    • 27437
                    • 49 Posts
                    for now, i’ll hack a display:none; around it

                    silly but it works
                      • 10442
                      • 3 Posts
                      Hello,
                      Thank you very much for your Multilingual add on, it is working quite nice on my website.

                      However, I have pages that I would like not to include in the normal menu (that changes according to the language) but that are always on top right part of my website. These pages are Home, About and Contact. As I am a full newbie both in modx and coding, I am unable to manage these page from being language changing.

                      the website looks something like this, with "menu" being the normal menu called by the following code in the template.
                      <li> [!Wayfinder? &startId=`[+LanguageID+]`!] </li>


                      +--------------------------------------------+
                      | Home| About | contact
                      FR| EN |
                      +--------------------------------------------+
                      | welcome | |
                      | "menu" | content |
                      | | |
                      +--------------------------------------------+

                      Could someone explain me how to change the right items when the language changes? I thought of creating an About and a contact page per language folder, and putting
                      <li><a href="#language code#/about.html" title=" [*pagetitle*]"> [*pagetitle*]</a></li>


                      #language code# being the gb for english, fr for french, etc... depending on the language the visitor has selected. unfortunately I don’t know what code to put for #language code# so that it changes in the two letters language code..

                      Furthermore, how could I make the Welcome message on top of "menu" language dependent too? (at the moment it is written like this in my template).

                      Thank you for your help, and sorry if my questions seem obvious.