We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    should have thought of that.
    when I try it in my ManagerCode Chunk (which is visible on Welcome) I see the plain call.
    when I add the call to welcome.static.php I get parse error because of the [ in the call.

      • 11975
      • 2,542 Posts
      Hi

      as dev_cw said you have to use the $modx->runSnippet function in a php page.
      The snippet call won’t be interpreted in the back end.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 27330
        • 884 Posts
        that’s hot, working magically. $modx->runSnippet function is really nice.

        Now this is some basic php so don’t get mad at me smiley
        anyone can tell whats the correct way to have multi parameters in the ditto call like so:

        //ditto test
        $dittoOutput = $modx->runSnippet(
                "Ditto",
                array(
                      "tpl" => "<post><title>[+title+]</title><summary>[+summary+]</summary></post>"
                    "parents" => "0"
                    "display" => "all"
                   
                )
        );
        
          • 7231
          • 4,205 Posts
          You could also do:
          <?php
          //set the params
          $params['tpl'] = "@CODE <post><title>[+title+]</title><summary>[+summary+]</summary></post>";
          $params['parents'] = "0";
          $params['display'] = "all";
          
          //execute the snippet
          return $modx->runSnippet("Ditto",$params);
          ?>


          The main diff being that here we set the params array first then execute, in the other example the array is set within the snippet call. Both work the same. Note that I used the @CODE binding, I think that this is needed if you are using the code directly in the tpl rather than a chunk.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 27330
            • 884 Posts
            just saw in the wiki http://wiki.modxcms.com/index.php/API:runSnippet

            with just what I needed.

            some styling and custom tpl and this thing will change my whole modx experience wink
              • 27330
              • 884 Posts
              thanks for the replies! it’s amazing what u can do with modx smiley

              I have one more question if I may, I’m using the $dashboard from the wiki here to add items to the welcome screen, but now I want to add the Ditto call as well to same variable if I can.
              no matter what I try I get parse errors. can someone correct me please how to do that?

              // setup dashboard variable
              $dashboard = $modx->getChunk('managerCode'); 
              $dashboard = (
              //set the params
              $params['parents'] = "0";
              $params['display'] = "10";
              //execute the snippet
              return $modx->runSnippet("Ditto",$params);
              )
                • 7231
                • 4,205 Posts
                You are setting the dashboard 2x thus eliminating the 1st command. And you have some bad syntax in the second dashboard command.

                Try it like this (note, added the php tags t get pretty colors):
                <?php
                //set the params
                $params['tpl'] = "managerCode";
                $params['parents'] = "0";
                $params['display'] = "10";
                
                //execute the snippet and load it into the dashboard variable
                $dashboard = $modx->runSnippet("Ditto",$params);
                ?>

                Now follow the tutorial from the "// setup message info" section by adding concatenating (adding to the variable by using the . ) the $msg variable
                $msg = $dashboard . '


                You did not need to do the first part since you are using Ditto to get the data not the getChunk api.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 27330
                  • 884 Posts
                  Thanks shane, sorry I was not clear. I want to use both, ie, the Get Chunk for manual links ( had them before in my welcome.html page) , and then also have the ditto call/calls underneath that why I repeated the $dashboard, thought maybe it’ll output both.
                    • 7231
                    • 4,205 Posts
                    OK, in that case you need to simply append the dashboard to include the chunk:
                    <?php
                    $dashboard = $modx->getChunk('managerCode'); 
                    
                    //set the params
                    $params['tpl'] = "yourTPL here"; // change this to your tpl
                    $params['parents'] = "0";
                    $params['display'] = "10";
                    
                    //execute the snippet and load it into the dashboard variable
                    $dashboard .= $modx->runSnippet("Ditto",$params);
                    ?>
                    By changing the = to .= to the second dashboard declaration we are adding to the original $dashboard var rather than overwriting it.
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 27330
                      • 884 Posts
                      thanks a lot Shane. really appreciate the explanation.
                      so if I wanted to add more blocks i can just add them in another $dashboard .=?