We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    I need to change this snippet so I can do:

    When ID or Parent = 1 then output chunk X
    or
    id / parent = 2 then output chunk Y
    else
    chunk Z

    [!ShowStuff? $docId=`[[*id]]`!]


    <?php
    /* ShowStuff Snippet */
    $output = '';
    switch($id) {
       case 1:
       case 2:
           $output = 'a';
           break;
      
       default:
           $output = 'z';
           break;    
      
    }
      
    return $output;

    This question has been answered by yama. See the first response.

    [ed. note: fourroses666 last edited this post 13 years, 5 months ago.]
      Evolution user, I like the back-end speed and simplicity smiley
      • 9995
      • 1,613 Posts
      Anyone?
        Evolution user, I like the back-end speed and simplicity smiley
      • discuss.answer
        • 33014 ☆ A M B ☆
        • 1,231 Posts
        <?php
        /* ShowStuff Snippet */
        $output = '';
        $id = $modx->documentObject['id'];
        switch($id) {
           case 1:
           case 2:
               $output = '{{a}}';
               break;
           
           default:
               $output = '{{z}}';
               break;   
           
        }
           
        return $output;

        How?
          • 9995
          • 1,613 Posts
          Thx Yama,

          I was not sure it would break because of the { }

          How to get this working on Parents of the ID too?

          [ed. note: fourroses666 last edited this post 13 years, 5 months ago.]
            Evolution user, I like the back-end speed and simplicity smiley
            • 9995
            • 1,613 Posts
            Nevermind, it doesn't work when loading a ditto chunk. sad

            Just did it by making a selectable dropdown TV



            [ed. note: fourroses666 last edited this post 13 years, 5 months ago.]
              Evolution user, I like the back-end speed and simplicity smiley