We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33657
    • 128 Posts
    how can i do this?

    		  [[*id:isnot=`48`:isnot=`51`:isnot=`52`:isnot=`53`:then=`
    		  <p>whatever i want</p>
    		  `]]


    i tried
    `48,51,52,53`


    not able to wrap my head around how to do it.
      • 3749
      • 24,544 Posts
      That looks like you might want a custom snippet. Here's one version (untested):

      [[!IfNotInList?  &list=`48,51,52,53` &show=`<p>whatever I want</p>`]]


      <?php
      /* IfNotInList snippet */
      
      $output = "";
      $listArray = explode(',', $scriptProperties['list']);
      if (! in_array($modx->resource->get('id'), $listArray)) {
         $output = $scriptProperties['show'];
      }
      
      return $output;


      You could also create a template variable that determines whether your output is shown. Something like this:

      [[!*TvName:empty=`<p>Whatever I want</p>`]]
        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
        • 33657
        • 128 Posts
        gotcha. yeah the reason I ask is because I want to use the same template for a News and Events section..

        the same template shows 1 post of each (news, blog, events) and then if you click one of the events I want it to show "that" post, or if you click a tag, i want it to show all the tags, etc..

        so basically I am doing a getResources call based on the ID. like if id = 50 call the blog get resource, etc, if 51, call events, if 52 call Press releases, etc.. but then if its not 50, 51, or 52 its a post, so call content

        i ended up just saying if greater than 52 call content... which is kinda tricky, but i guess its no different than making a custom snippet to do the same thing...


        actually... on second thought your snippet is pretty awesome, so i am just going to use that and I like that idea any maybe I can expand on it! smiley [ed. note: zurie last edited this post 15 years ago.]