We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36112
    • 24 Posts
    Hi everyone

    I'm strugglig with creating TV based chunks to display different wayfinder menus on different language pages... I'm trying to create a page where you can choose between 4 different languages, I've set up my resources tree as described on various topics like i.e. "en/welcome" and so on..

    This is what I have so far.. hope someone can help me on this...

    Snippet: (getChunk) from http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
    <?php
    /* Get the category object */
    $catObj = $modx->getObject('modCategory',array('category'=>$category));
     
    /* Get the chunk objects in that category */ 
    $chunkArray = $catObj->getMany('Chunks'); 
     
    $chunkNames=array();
     
    /* Put the chunk names into the array */ 
    foreach($chunkArray as $chunk) {
        $chunkNames[] = $chunk->get('name');
    }
     
    /* Format the chunk names as a delimited string for the TV */ 
    $l_chunks = implode("||",$chunkNames); 
    return $l_chunks;


    Chunks (4 of them) in category "Selected":
    menu_no / menu_en / menu_da / menu_sv
    [[Wayfinder? &startId=`2` &level=`4` &outerTpl=`wayfinder_outer_tpl` &innerTpl=`wayfinder_inner_tpl` &hereClass=`current`]]


    TV: Radio buttons
    @EVAL return $modx->runSnippet('getChunks',array('category'=>'Selected'));



    I'm I missing something here? The only thing I want to change is the startId of the wayfinder call, to get the correct menu displayed..

    Hope someone could help with this one, or if you have any other ways to do this...

    Thanks

      • 4172
      • 5,888 Posts
      If the only property, you want to change, is the startId, you can use a TV (name: langStartId) with input-option-values like that:

      no==40||en==50||da==60||sv==70


      your call in your template would be:

      [[Wayfinder? &startId=`[[*langStartId]]` &level=`4` &outerTpl=`wayfinder_outer_tpl` &innerTpl=`wayfinder_inner_tpl` &hereClass=`current`]]


      I don't know your pagetree-structure and which startId you are looking for, but perhaps you can just use the ultimateParent - snippet to get the correct startId for each language?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        That is why I originally wrote the UltimateParent snippet many years ago, to provide the top-level ID for a multi-language site. The four top-level resources provided the home page for each language. I used a cookie to maintain the ID of the "home" page for the visitor. The language menu was a simple Wayfinder snippet.

        Of course, this meant editing four different resources every time something needed to be changed or edited, and using TVs for each language version of a resource, as YAMS does, is a much nicer solution, although it does require a much more complicated management system to set up in the beginning.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 36112
          • 24 Posts
          @Bruno17 - That worked like a charm... Tried that before doing all the chunks, but couldn't get it to work :S... Thanks! Exactly as I need it to work smiley

          @sottwell - UltimateParent seems perfect for this kind of work! Do you have any example wayfinder calls using this?

          As always, thanks for the quick replies!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            [[Wayfinder? &startId=`[[UltimateParent]]` &level=`1`]]
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org