We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3866 ☆ A M B ☆
    • 350 Posts
    Hi there,

    I've been successfully creating custom tables making use of MIGXdb and info a http://bobsguides.com/custom-db-tables.html and I have made use of Rowboat to loop over the rows in my tables, and I can filter the data making use of the &where= property.

    What I would now like to do is add the value from getURLParam into the &where property - is this possible or am I looking at some other solution to this query.

    An example would be where the url was www.mydomain.com/index.php?id=15&cat=5 and I want to pass the value of &cat=5 into the &where=`{"cat:LIKE":"5"}`

    Suggestions please. [ed. note: boomerang last edited this post 13 years, 4 months ago.]
      Helen Warner
      Number one pixel!
      Proud to be linked with MODX at Crimson Pixel
      • 32699 ☆ A M B ☆
      • 427 Posts
      Try dropping the value in with a placeholder:

      &where=`{"cat:LIKE":"[[+placeholder]]"}`

      I do not know what your cat is, but you could also pass [[*parent]] for the ID of the Parent Resource or [[*id]] for the current resource.
        Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

        Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
        • 3866 ☆ A M B ☆
        • 350 Posts
        Hi Shawn,

        Cat is short for category, I want to return all data from a custom table which is in a particular category.

        The getUrlParam snippet doesn't have the option to set to placeholder. I'm assuming I need to add something to this snippet so that it would output to a placeholder. Would it simply be a case of adding:

        $modx->toPlaceholder('category');


        Here is the full snippet without any changes.

        // set defaults
        $name = $modx->getOption('name',$scriptProperties,'p');
        $int = $modx->getOption('int',$scriptProperties,false);
        $max = $modx->getOption('max',$scriptProperties,20);
        $output = $modx->getOption('default',$scriptProperties,'');
        
        // get the sanitized value if there is one
        if (isset($_GET[$name])) {
            if ($int) {
                $value = intval($_GET[$name]);
            } else {
                if (strlen($_GET[$name]) > $max) {
                    $value = filter_var(substr($_GET[$name],0,$max), FILTER_SANITIZE_STRING);
                } else {
                    $value = filter_var($_GET[$name], FILTER_SANITIZE_STRING);
                }
            }
            $output = $value;
        }
        
        return $output;


        Thanks
          Helen Warner
          Number one pixel!
          Proud to be linked with MODX at Crimson Pixel
          • 3866 ☆ A M B ☆
          • 350 Posts
          Ok, thanks to Shawn and the post https://forums.modx.com/index.php?topic=37698.0 I have added the line to the getUrlParam snippet which has set my placeholder.

          $modx->setPlaceholder('category',$output);


          I have then used the placeholder as follows:

          [[!Rowboat? &table=`my_table` &tpl=`category`  &limit=`10`  &where=`{"id:LIKE":"[[+category]]"}`]]


          I then added to Rowboat getPlaceholder as follows:

          $modx->getPlaceholder('category');


          And it all seems to work fine.
            Helen Warner
            Number one pixel!
            Proud to be linked with MODX at Crimson Pixel