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

    New to the ModX scence and looking for a little bit of help huh

    Essentially what I am trying to do is output a list of documents that have specific TV value.

    For example, imagine I have a global TV across all documents with Yes/No.

    If the value within a particular document is ’Yes’ (and there are ten pages each selected as yes), then the list would output as 1,2,3,4,5,6,7,8,9,10 or something along those lines. Say 2,3,4 are ’No’ then the list would ouput as 1,5,6,7,8,9,10.

    Ideally this would also work vice-versa so I could produce a list of ’No’ documents as well.

    Essentially I am trying to make the XML sitemap controllable for my client, allowing them the ability to exclude and include certain pages from their sitemap. I am using gsitemap plugin that the mo, but this only allows me to exclude pages by hard-coding the IDs into the call.

    Thanks in advance.

    Regards

    Craig

    P.S - Loving the functionality of Revo. OMG... never new a CMS could be so powerful yet flexible. Great community here as well guys, and I’ll certainly be contributing once I’m up to speed wink
      • 3749
      • 24,544 Posts
      I couldn’t find a plugin or snippet called gsitemap. From your description, it sounds like a snippet (rather than a plugin) with a property to include or exclude resources using a comma-delimited list. If so, you could write your own snippet to build the list based on the TV and use that in the snippet property. Say your snippet is called SelectDocs, and the TV is called ShowDoc, the call would use this:

      [[gsitemap?  &exclude=`[[SelectDocs? &show=`1`]]` . . .]]


      And your SelectDocs snippet would look something like this (untested):

      <?php 
      $docs = $modx->getCollection('modResource', array('published'=>'1', 'hidemenu'=>'0', 'deleted'=>'0'));
      
      $selected = array();
      
      foreach($docs as $doc) {
          /* select all docs where the ShowDoc TV value matches the &show property */
          if ($doc->getTVValue('ShowDoc') == $show) {
              $selected[] = $doc->get('id);
          }
      return (implode(',', $selected));
      
      }


      Changing to &show=`0` would show the docs with the TV set to "No".

      I think you could also do it with getResources and its &tvFilters property. I’m not sure which would be faster.
        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
        • 5901
        • 11 Posts
        Hi Bob,

        Thanks for getting back to me. Decided to go down the getResources route and ditch the snippet all together. There is a great tutorial on building an XML sitemap using getResources at http://rtfm.modx.com/display/ADDON/getResources.Google+XML+Sitemap.

        Thanks again for pointing me in the right direction.

        Craig laugh