We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12410
    • 353 Posts
    Hi Guys,
    http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29 mentions the use of the OR and AND conditional.
    How would I integrate OR into the below code so that if
    id=1
    OR
    id=2
    then...hello world

    [[!*id:is=`1`:then=`hello world`]]


    I'm stuck on the syntax - Thanks
      • 12410
      • 353 Posts
      ok this seems to work. someone may find it useful

      [[!*id:is=`1`:or=!*id:is=`2`:then=`hello world`]]
        • 12410
        • 353 Posts
        ok new problem sad

        Anyone know the syntax to say if parent id is 1 or page id is 1 then output hello world.

        [[!*parent:is=`1`:or=!*id:is=`1`:then=`hello world`]]


        if i have the following navigation

        animals
        >dog
        >cat
        >horse
        people
        >joe
        >mary
        >kate

        I am trying to use conditionals so i only have to use 1 template but vary the code based on parent id or page id conditionals

        Thanks
          • 32316
          • 387 Posts
          whistlemaker Reply #4, 15 years ago
          What is 'the code' in
          but vary the code
            • 36620
            • 65 Posts
            I would create a simple custom snippet:
            <?php
            $pageId = $modx->resource->get('id'); 
            $parentId = $modx->resource->get('parent');
            if ($pageId=="1"||$parentId=="1") $output="hello world"; 
            return "$output";
            ?>

            I'm using Evolution so cannot test the snippet but I'm sure some Revo user will hopefully correct any mistake I've made.
            [ed. note: randall last edited this post 15 years ago.]
              • 3749
              • 24,544 Posts
              I would remove the quotes around $output. wink

              And I'd put this at the top:

              $output = "";
                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