On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • If I'm understanding you, you don't need a switch. Just something like this:

    $id = $modx->resource->get('id');
    $parent = $modx->resource->get('parent');
    if (($id == 1) || ($parent == 1)) {
        return '[[Ditto . . .]]';
    return '';

    Oh, Oh. I just realized that if it's Ditto, you're probably using Evolution. You could leave out the first line, but I can't remember how to get the parent ID in Evo. It might be set, if so, you can just delete the first two lines.
      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
    • This should work for Evolution:
      $id = $modx->documentObject['id'];
      $parent = $modx->documentObject['parent'];
      $output ='';
      if( $id == 1 || $parent == 1 ){
          $output .='[[Ditto . . .]]';
      return $output;
        http://frsbuilders.net (under construction) forum for evolution
      • Thanks guys, I haven't tried ditto directly into the snippet.

          Evolution user, I like the back-end speed and simplicity smiley
        • Or you could runSnippet('Ditto', array(...)) and return it; that would save further processing in the next pass of the parser.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
          • I'm busy with an other project, and need to be able to say;

            if id=1 then load chunk main-home
            if id=4 then load chunk main-gallery
            else = chunk main-standard

            But main-home has also some ditto call into it, this doesn't work.

            So I can probably use a phx:modifier which allows dittocalls into it?!

            But how do I use it?

            I think I did do one some time ago but can't remember how I did it and on what project.

            Documentation says:

            I have paste the snippet code and called the snippet switch but doesn't work:

            Anyone can point me in right direction?
            Can't load a snippet into a snippet


            I guess it does work when I call my Ditto uncached!
            For peoples who might want to use this:

            My call:

            My snippet:
            // set the default ids of the top level parent containers
            $default_parent_ids = array();
            // set the default names of the chunks to display
            // based on the same order as the $parent_ids
            $default_chunk_names = array();
            // set the overall default chunk name
            $default_chunk_name = isset($def_chunk_name) ? $def_chunk_name : '';
            // ===== end setup ===== //
            $parent_ids = isset($parent_ids) ? explode(',',$parent_ids) : $default_parent_ids;
            $chunk_names = isset($chunk_names) ? explode(',',$chunk_names) : $default_chunk_names;
            if(count($parent_ids) > 0 && count($chunk_names) > 0){
                $uparent = $modx->runSnippet('UltimateParent');
                $check_array = array($modx->documentObject['id'],$modx->documentObject['parent'],$uparent);
                for($x=0; $x < count($parent_ids); $x++){
                        $print_chunk = $chunk_names[$x];
                // if $print_chunk is empty set to overall default
                if($print_chunk ==''){
                    $print_chunk = $default_chunk_name;
            return $modx->getChunk($print_chunk);

            Main-home chunk has this dittocall:
            &orderBy=`menuindex ASC` 
            &noResults=`No news..` 
            [ed. note: fourroses666 last edited this post 6 years, 10 months ago.]
              Evolution user, I like the back-end speed and simplicity smiley