We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28554
    • 201 Posts
    Hi guys,

    Still asking questions, hope you don’t mind. When I’m done with my site I’m gonna bundle it all into a big-ass tutorial for all to see, but first things first.

    So I’ve been working on my portfolio. It has "cases", and "services". I want to make a Multi-select in the caseEntry which reads out the children of the page "Services", and then list the services with links to them. I’ve already figured I have to Ditto the results along the lines of:

    [[Ditto?tpl=`servicesList`&documents=`[*services*]`]]
    


    But I’m not quite sure how to construct the @SELECT binding in the TV "services". I want to be able to select the services by the name of the page (pagetitle?), and have it return the ID’s of the pages separated by a comma.
      • 4172
      • 5,888 Posts
      TV type: multiselect
      as delimited list
      delimiter: ,

      input option values:

      @SELECT id,pagetitle from `modx_site_content` where parent=yourParentID

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 28554
        • 201 Posts
        Quote from: Bruno17 at May 12, 2010, 02:06 PM

        TV type: multiselect
        as delimited list
        delimiter: ,

        input option values:

        @SELECT id,pagetitle from `modx_site_content` where parent=yourParentID



        Thanks, that was rly easy. The select was the other way around, but I get the point, I’ve corrected it above. Can I assume that this is the syntax for @SELECT-bindings: separate the values by a comma makes you select by the first, and will return the second?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          No, @SELECT works exactly like a SELECT query. In the above case, the id and the pagetitle of the resource will be returned, again exactly as a SELECT query would return it.

          The relevant lines from tmplvars.commands.inc.php -
          $rs = $modx->db->query("SELECT $param;");
          $output = $rs;
          
            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
            • 36416
            • 589 Posts
            Quote from: StevenLangbroek at May 12, 2010, 03:20 PM

            Can I assume that this is the syntax for @SELECT-bindings: separate the values by a comma makes you select by the first, and will return the second?

            Yes, even if @SELECT only execute given SQL, dropdown list will format it as label from 1st field value, and selection value from the second field.
              • 28554
              • 201 Posts
              Quote from: sottwell at May 12, 2010, 11:37 PM

              No, @SELECT works exactly like a SELECT query. In the above case, the id and the pagetitle of the resource will be returned, again exactly as a SELECT query would return it.

              The relevant lines from tmplvars.commands.inc.php -
              $rs = $modx->db->query("SELECT $param;");
              $output = $rs;
              


              Hm... well I haven’t quite tested it through yet, so how would I construct it to only return the ID, but let me select it by name?

              [i]Edit: well, turns out that it does do as I said: The TV lets me select by name, and will return the ID’s of the pages...[.i]
                • 20413
                • 2,877 Posts
                I guess you meant to post this here: http://modxcms.com/forums/index.php/topic,49328.msg287927/topicseen.html#msg287927

                In Ditto snippet call: &documents=`[*yourTV*]`
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 28554
                  • 201 Posts
                  Quote from: mrhaw at May 13, 2010, 02:30 PM

                  I guess you meant to post this here: http://modxcms.com/forums/index.php/topic,49328.msg287927/topicseen.html#msg287927

                  In Ditto snippet call: &documents=`[*yourTV*]`

                  No that’s a different post. I have services on my website. They’re all children of the "Services" page (where I Ditto them). I want to Ditto the children of the page "Services", except the child that’s now being shown.
                    • 20413
                    • 2,877 Posts
                    add &filter=`id,[*id*],2`
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:
                      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                      • 28554
                      • 201 Posts
                      Quote from: mrhaw at May 13, 2010, 04:50 PM

                      add &filter=`id,[*id*],2`

                      Thanks! Worked like a charm smiley. Ditto really is an absolutely amazing piece of kit smiley.