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

    I am about to setup a page where all the galleries of my website are listed. I have found out that the best way for this is to use ditto and call MaxiGallery from within the ditto template.

    As only some of my pages do have a gallery, I need to tell Ditto wich documents to use.

    I have not found any hint to achieve this easily, so I decided to code a little snippet for that. I announce it here, beacause I wish you to stop me, if you know there is already a solution wink

    I will post my snippet here when i’m finished.

    Greetings
    Martin
      • 4310
      • 2,310 Posts
      If they use a specific template then you can use the Ditto filter system to filter out any pages not using said template.
        • 10313
        • 375 Posts
        Well they don’t. Virtually any page can be given a gallery.

        That’s why I made this liitle snippet [tt]getMGids[/tt]:

        <?php
        $mgTabName = isset($mgTab)?$mgTab:"maxigallery";
          $mgTable = $modx->getFullTableName($mgTabName);
          $contentTable = $modx->getFullTableName("site_content");
          
          $sql = "select distinct inh.ID from $contentTable as inh right join $mgTable as mg on inh.id=mg.gal_id where 1";
        
          $rs = $modx->db->query($sql);
          $docs = "";   
          while($bc = $modx->db->getValue($rs)){
            $docs .= $bc . ",";
          }
          $docs = rtrim($docs, ",");
          return $docs;
        ?>

        This snippet returns a comma separated list of document IDs wich can be used for Ditto’s [tt]&documents[/tt]-parameter.
        You can use the appropriate Ditto-parameters to view hidden or unpublished pages.

        Martin
          • 26931
          • 2,314 Posts
          hey FuryDE, thanks for sharing smiley *bookmarked*