We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48586
    • 78 Posts
    I would like to display a modified version of one of my chunks on certain resource id's, and leave it as default on all other pages. I came across an old post on doing this for the homepage only, but I would like to verify the code to pull the correct id's. Thank you in advance.

    For template:

    [[!snippetName? &extendedChunk=`SomeChunkName` &basicChunk=`SomeOtherChunkName`]]


    Snippet code:

    <?php
    
    if ($modx->resource->get('id') == ('18','22','24','26')) {
      $chunk = $extendedChunk;
    } else {
       $chunk = $basicChunk;
    }
    return $modx->getChunk($chunk);


    The part I am having trouble with is how to call the id's. Thanks.

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

    • discuss.answer
      • 4172
      • 5,888 Posts
      try this:

      <?php
      
      $ids = explode(',',$modx->getOption('ids',$scriptProperties,''));
      $docid = $modx->resource->get('id');
       
      if (in_array($docid,$ids)) {
        $chunk = $extendedChunk;
      } else {
         $chunk = $basicChunk;
      }
      return $modx->getChunk($chunk);
      


      [[!snippetName? &ids=`18,22,24,26` &extendedChunk=`SomeChunkName` &basicChunk=`SomeOtherChunkName`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 48586
        • 78 Posts
        Thank you very much, I really appreciate the help.