We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5430
    • 247 Posts
    I'm using
    @SELECT `pagetitle` AS `name`,`id` FROM `[[+PREFIX]]site_content` WHERE `published` = 1

    To populate a multiselect listbox TV. I want to limit this to the current context (I've got 10 contexts running). Is there someway to grab the current context and include it in my WHERE statement or am I going to be stuck using @EVAL to run a snippet to populate the variable instead of @SELECT?

    Basically, I'd like to do something like
    @SELECT `pagetitle` AS `name`,`id` FROM `[[+PREFIX]]site_content` WHERE `published` = 1 AND `context_key` = [[*context_key]]

    but obviously i can't use a tag here. Can I run @EVAL inside @SELECT to return a value from a snippet?

    Any ideas?
      • 3749
      • 24,544 Posts
      I'm not sure if that would work or not (I kind of doubt it).

      You should be able to use @eval with runSnippet() and have the snippet do the query and return the formatted results.


      You might also be able to do it with a property (with Pre-process tags in Property Values checked).
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting