We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10638
    • 57 Posts
    Hi, I am trying to get my head around binding, but I have become stuck, please help!

    @EVAL if ($modx->getLoginUserID()) return '@CHUNK chunk_name'; else return 'something else';



    Is this kind of nested binding possible? (forgive me if I am way off track here grin )

    I was hoping to evaluate if the user was logged into the manager, and if the user is, then I want the string to basically be empty, but if the user isn’t logged into the manager I want it to insert the content of a chunk I have setup into the TV field.

    The reason I am attempting this is because MODx Evolution comes with the brilliant jQuery lightbox (colorbox) used for editing documents through the front-end, and I want to be able to use colorbox in conjunction with the MaxiGallery snippet.

    So instead of inserting the JS, the links to the JS and the links to the CSS twice (one handled by the front end editor plugin, the other from the TV) I wanted to evaluate what I mentioned above.

    Then hopefully I can use the @INHERIT binding to have each sub-gallery evaluate the same thing.

    Hopefully this is the right way to go about this! If anyone could point me in the right direction I would be much appreciative. laugh

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      No, this isn’t possible because the @EVAL statement takes the following content and runs it through the PHP eval() function, where such things as @EVAL have no meaning. You could use $modx->regClientStartupScript(’whatever’) there, however.

      Consider a TV using @EVAL to be the same as a snippet. In fact, you could just as easily use the MemeberCheck or some similar snippet in your document’s content, with a TV for specifying which chunkname to use (or whether to have the regClientStartupScript function call).
        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
        • 10638
        • 57 Posts
        Thank you for your help. smiley