We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4295
    • 98 Posts
    How do you use a MODx tag as a string inside a SELECT statement?

    I created a TV with @SELECT like below and chose "Hyperlink" as the Widget.
    @SELECT pagetitle,CONCAT('index.php?id=',id) as 'id' FROM `modx_site_content` WHERE `pagetitle` LIKE 'f%' ORDER BY `pagetitle` ASC LIMIT 40;


    Instead of the string ’f%’ I need this to be the menu title with wildcard -- I’ve tried this -- ’[*menutitle*]%’ -- but it doesn’t work. Could someone explain? Sorry for the stupid noob question.

    [moderator note: subject edited for clarity]
      • 22303 MODX Staff
      • 10,725 Posts
      It’s not a stupid question at all. This currently is not possible, as the SELECT content is not parsed. However, placeholders are replaced in it, so you could theoretically execute something to set placeholders to accomplish this (i.e. set $modx->setPlaceholder(’placeholderkey’, $somevalue); in a snippet and then place [+placeholderkey+] in the @SELECT binding).

      This will likely not be possible in 0.9.5 either, but in releases following, you’ll be able to use MODx tags in @SELECT bindings, and lot more places than is currently possible.
        • 4295
        • 98 Posts
        Jason, thanks for the reply. I appreciate it. I had trouble getting the placeholder thing working properly. I decided to create several snippets with different LIKE parameters and I’ll revisit these later and turn them all into a single snippet when MODx tags are directly supported in SELECT.

        I tweaked my SELECT as shown below to fake my FURLs so am happy. I’m slowly knocking out all the features I wanted, slow, but sure. Thanks again for taking the time to explain. Later.

        @SELECT pagetitle,CONCAT('index.php?q=', alias, '.html') as 'id' FROM `modx_site_content` WHERE `pagetitle` LIKE 'f%' ORDER BY `pagetitle` ASC LIMIT 40;