We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7914
    • 137 Posts
    Hello, I have asked and received an answer, but frankly I just don’t understand the answer. It has to be obvious -- I’ve been trying to wrap my thick head around it but just haven’t had any luck.

    I am using a snippet to check which page/container I’m on:
    if ($file == 'my-page.php' || $container == 'my-container')
    {
        $tpl = "[[Wayfinder? &startId=`0` &outerTpl=`SideNavigation` &rowTpl=`SideNavigationRows` &titleOfLinks=`longtitle' &includeDocs=`11`]]";
    }
    
    return $tpl;
    


    This is actually working, but because of the feedback I got before, I have this feeling that it’s just dumb luck that it is working.

    I know I can’t call MODx tags within php; they don’t know about each other. I need to use an array to call the MODx snippet. In the example I was given:
    $modx->runSnippet('snippetName', array('param1'->'value1', ...));
    


    I would come up with something like:
    $modx->runSnippet( 'Wayfinder', array('&startId'->'0',...) );
    


    But, that’s just not the right syntax.

    Sorry guys... my skull must be really thick on this one. undecided
      • 3749
      • 24,544 Posts
      Almost:


      <?php
      $modx->runSnippet( 'Wayfinder', array('startId'=>'0',...) );
      ?>
      


      => not ->
        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
        • 7914
        • 137 Posts
        ah... DUH.

        Thank you for your help. That set off the "got it" reaction.

        Here is what I came up with for anyone else running into this...may be of some help.
        if ($file == 'my-file.php' || $container == 'my-container')
        {
            // set up params for the page
            $params['startId'] = '0';
            $params['outerTpl'] = 'MyOuterTemplate';
            $params['rowTpl'] = 'MyTemplateRow';
            $params['titleOfLinks'] = 'longtitle';
            $params['includeDocs'] = '11';
            
            // return the markup
            $html .= $modx->runSnippet('Wayfinder', $params);
        }
        
        return $html;