We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26401
    • 247 Posts
    Is there a way to pass a parameter to a chunk?

    I’d like to do some thing like this
    {{MyChunk? &param=`myParameter`}}

    and be able to usesomething like [+param+] inside the chunk

    I guess the snippet is better for something like this, but I figured for something this simple there might be a way to do that rather then writing an extra snippet
      • 25663 MODX Staff
      • 12,272 Posts
      Yes. Download MODx Revo beta and your wish is realized today. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 26401
        • 247 Posts
        So this feature is not supported in 0.9.6?

        How do I pass parameters to a chunk then?

        I noticed that one of the chunks {{mh.RowTpl}} has is using variables that are not defined
        <li class="category [+wf.classnames+]"><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>

        is it possible to send a placeholder to the chunk from a non-snippet?
          • 33337
          • 3,975 Posts
          In Evo, there is no way you can do that AFAIK.
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 26401
            • 247 Posts
            ok, well if anyone else needs to do this, this is what I’ve done

            [[PassParameter]]
            pass a parameter(&pName)(&pVal) to a chunk(&tpl)

            <?php
            // Set parameter to parse
            $params[$pName]=$pVal;

            // Carry out chunk &tpl
            $documentOutput.=$modx->parseChunk($tpl, $params, ’[+’, ’+]’);

            // Output
            echo($documentOutput);
            ?>

            usage
            [[PassParameter? &pName=`itemID` &pVal=`1` &tpl=`myTemplate`]]