We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7858
    • 97 Posts
    Hi, how can I use @EVAL in custom rendered?

    I'm trying

    @EVAL return $modx->runSnippet('getListboxVal');


    and it brokes my CMP...

    This question has been answered by Bruno17. See the first response.

      • 4172
      • 5,888 Posts
      what's the whole code of your renderer and the code of your snippet?
      you can try to use the renderChunk-renderer and put a snippet-call there.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 7858
        • 97 Posts
        I'm just trying to get NAME instead of VALUE from listbox TV. There must be snippet parameters in a call (tv name and value), i've ommited for example. Am I doing it wrong? (

        Snippet code is:

        <?php
        $tvn = 'mxAges';
        $value = intval(6);
        $name = '';
        if ($tvn) {
            $tv = $modx->getObject('modTemplateVar',array('name'=>$tvn));
            $elements = $tv->get('elements');
            $i=0;
            $tvElements = array();
            foreach(explode("||",$elements) as $val){
                $vl = explode("==",$val);
                $tvElements[$i]['name'] = $vl[0];
                $tvElements[$i]['val'] = $vl[1];
                $i++;
            }
            
            foreach ($tvElements as $element) {
                if($element['val'] == $value){
                    $name = $element['name'];
                }
            }
            return $name;
        }
        else{
            
            return '';
        }
        • discuss.answer
          • 4172
          • 5,888 Posts
          yeah, you can use the renderChunk - renderer.
          Do not use the original field for that column.
          Create another column with an unused fieldname to render that value!

          In the renderchunk Tpl call you snippet

          [[getListboxVal? &value=`[[+theListboxField]]`]]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 7858
            • 97 Posts
            Thnx, works like charm