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

    I’m working on a multilingual website.
    For a TV, I need according to UltimateParent value to change the TV values (checkbox)
    I’ve tried to write a fast php code to return the value list with @EVAL

    here is the code:

    @EVAL $ultimate = $modx->runSnippet('UltimateParent'); 
    switch($ultimate){ 
    case 58: //root folder for French version
    $values = "value1-FR||value2-FR||valueN-FR"; 
    return $values; 
    break; 
    
    case 71: //root folder for UK version
    $values = "value1-UK||value2-UK||valueN-UK";
    return $values;
    break;
    
    case 109://root folder for German version
    $values = "value1-DE||value2-DE||valueN-DE";
    return $values;
    break;
    }
    


    Any idea about what to change in this code to achieve this???

    Thx
      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
      • 11975
      • 2,542 Posts
      Anybody huh

      I’ve tried several ways to achieve this but still unable to obtain the expected result.
      I’ve made a new snippet with this code called getListMulti and put in TV option values

      @EVAL global $modx; $list = $modx->runSnippet('getListMulti'); return $list;
      


      but didn’t work. I’m out of idea ....

      Any help greatly appreciated smiley
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 6726
        • 7,075 Posts
        Sorry never used @EVAL I can’t really help... one thing I noticed as an intensive forum user, is forum activity is slowing down spectacularly since the beginning of July... vacation time it seems ! I know because now I can keep up with the forum tongue

        I hope someone drops by to help, but it might take more time than usual to get it...
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 11975
          • 2,542 Posts
          I hope so cause This issue drives me crazy.
          I’ve read every thread about @EVAL but any mentionned technics worked for me.

          That’s really odd. If I’m putting this code in the default value field,
          @EVAL return $modx -> runSnippet(’UltimateParent’);
          Modx send me back the value.

          The same code in optionnal value doesn’t send anything.

          I woudn’t like to duplicate my TV and My template to figure out this issue.

          :-)
            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 17673
            • 194 Posts

            maybe it’s just the format of your $values variable that does not fit...
            $values = "value1-FR||value2-FR||valueN-FR";

            either try:
            $values = "value1==FR||value2==FR||valueN==FR"; (i.e. you need the ’==’ )

            or leave it in rows and columns, as it is stated in http://modxcms.com/what-are-at-bindings.html:

            controls that accept string values such as a radio button group or select list will attempt to convert a record set (rows and columns) into the following format:
            col1row1Value==col2row1Value||col1row2Value==col2row2Value,...
              ----------------------------------------------------------
              http://www.linkedin.com/in/lucapost/
              http://www.twitter.com/lukwe/
              ----------------------------------------------------------
              • 11975
              • 2,542 Posts
              Thx for your help
              but the issue doesn’t come from the values
              I’ve given these as an example.

              For now I cannot get that the php code be interpreted if entered in optional value field.
              the same code in default value field of TV works well.

              AS I told if i’m testing a simple snippet call with runSnippet function, It doesn’t send back any value.

              :-)
                Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                • 11975
                • 2,542 Posts
                As far as I know and after testing several way to write it, it seems that default value and optionnal are not handled in the same way by MODx.

                With default value this syntax works.

                in the default field:
                @chunk mychunk

                in mychunk:
                @eval return $modx->runSnippet(’UltimateParent’);

                Works as expected but the same call in optionnal values field doesn’t.

                Could a member of the core confirm that the fields are not managed in the same way by MODx

                thx.

                :-)
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l