We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3689
    • 264 Posts
    I have 3 Plugins, all with similar code to this
    //<?php
    
    $e = &$modx->Event;
    $output ='';
    
    switch($e->name) {
        case 'OnManagerWelcomeHome':
            // set parent ID
            $parentId = '4';
            
            // set the tpl - can also be done in chunks and use chunk name in the param array
            $rowTpl = 'homeCustom';    
            $outerTpl = '@CODE: <h3 class="h3pad">Current Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
            
            // set params for Wayfinder - params needs to be an array
            $params['startId'] = $parentId;
            $params['level'] = '1';
            $params['ignoreHidden'] = 'TRUE';
            $params['rowTpl'] = $rowTpl;
            $params['outerTpl'] = $outerTpl;
            
            
            // execute snippet
            $output = $modx->runSnippet('Wayfinder', $params);
        break;
           
        default:
            $output = '';
        break; 
    }
        
    $e->output($output);
    
    return;

    Only thing that changes between the 3 pages is the Parent ID and whats in the h3 tags.. the 3 are Current Properties, Pending Properties, and Sold Properties. They appear fine on the home page, but they aren’t in order.. How do I order them in this order:

    Current Properties
    Pending Properties
    Sold Properties

    ?
      • 3749
      • 24,544 Posts
      How about putting all the code in one plugin? Then you can generate the output in any order you like.
        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
        • 3689
        • 264 Posts
        Quote from: BobRay at Feb 20, 2010, 08:05 PM

        How about putting all the code in one plugin? Then you can generate the output in any order you like.

        I tried that before seperating the 3 plugins and it would only display 1 for some reason
          • 26931
          • 2,314 Posts
          did something similar ... here’s my plugin code: http://modxcms.com/forums/index.php/topic,43572.msg268852.html#msg268852
            • 3749
            • 24,544 Posts
            Quote from: BnH at Feb 20, 2010, 08:06 PM

            Quote from: BobRay at Feb 20, 2010, 08:05 PM

            How about putting all the code in one plugin? Then you can generate the output in any order you like.

            I tried that before seperating the 3 plugins and it would only display 1 for some reason

            Did you append the Wayfinder output to the $output variable with .= and have only one $e->output($output); at the very end of the plugin? Something like this:
            // set params
            $output = $modx->runSnippet('Wayfinder', $params);
            $output .= '<hr />';
            
            // set params
            $output .= $modx->runSnippet('Wayfinder', $params);
            $output .= '<hr />';
            
            // set params
            $output .= $modx->runSnippet('Wayfinder', $params);
            $output .= '<hr />';
            
            $e->output($output);
              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
              • 3689
              • 264 Posts
              Quote from: BobRay at Feb 21, 2010, 12:49 AM

              Quote from: BnH at Feb 20, 2010, 08:06 PM

              Quote from: BobRay at Feb 20, 2010, 08:05 PM

              How about putting all the code in one plugin? Then you can generate the output in any order you like.

              I tried that before seperating the 3 plugins and it would only display 1 for some reason

              Did you append the Wayfinder output to the $output variable with .= and have only one $e->output($output); at the very end of the plugin? Something like this:
              // set params
              $output = $modx->runSnippet('Wayfinder', $params);
              $output .= '<hr />';
              
              // set params
              $output .= $modx->runSnippet('Wayfinder', $params);
              $output .= '<hr />';
              
              // set params
              $output .= $modx->runSnippet('Wayfinder', $params);
              $output .= '<hr />';
              
              $e->output($output);


              i didnt do this.. is this what i would place at the end of the plugin? how would it know which parents to print?
                • 3749
                • 24,544 Posts
                My example is kind of a diagram for the whole plugin.

                Where I put the

                // params


                lines is where you would set all the params for each Wayfinder call (including the parents). IOW, the code from each of your three plugins that sets the params would go where those three comments are.

                  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
                  • 3689
                  • 264 Posts
                  Quote from: BobRay at Feb 21, 2010, 03:05 PM

                  My example is kind of a diagram for the whole plugin.

                  Where I put the

                  // params


                  lines is where you would set all the params for each Wayfinder call (including the parents). IOW, the code from each of your three plugins that sets the params would go where those three comments are.



                  k ill have to try it when i get home smiley thx!
                    • 3689
                    • 264 Posts
                    I tried this

                    //<?php
                    $e = &$modx->Event;
                    $output ='';
                    // set params
                    switch($e->name) {
                        case 'OnManagerWelcomeHome':
                            // set parent ID
                            $parentId = '4';
                            
                            // set the tpl - can also be done in chunks and use chunk name in the param array
                            $rowTpl = 'homeCustom';    
                            $outerTpl = '@CODE: <h3 class="h3pad">Current Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
                            
                            // set params for Wayfinder - params needs to be an array
                            $params['startId'] = $parentId;
                            $params['level'] = '1';
                            $params['ignoreHidden'] = 'TRUE';
                            $params['rowTpl'] = $rowTpl;
                            $params['outerTpl'] = $outerTpl;
                    		$output = $modx->runSnippet('Wayfinder', $params);
                    		$output .= '<hr />';
                    
                    // set params
                    switch($e->name) {
                        case 'OnManagerWelcomeHome':
                            // set parent ID
                            $parentId = '34';
                            
                            // set the tpl - can also be done in chunks and use chunk name in the param array
                            $rowTpl = 'homeCustom';    
                            $outerTpl = '@CODE: <h3 class="h3pad">Pending Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
                            
                            // set params for Wayfinder - params needs to be an array
                            $params['startId'] = $parentId;
                            $params['level'] = '1';
                            $params['ignoreHidden'] = 'TRUE';
                            $params['rowTpl'] = $rowTpl;
                            $params['outerTpl'] = $outerTpl;
                    		$output .= $modx->runSnippet('Wayfinder', $params);
                    		$output .= '<hr />';
                    
                    		$e = &$modx->Event;
                    		$output ='';
                    
                    // set params
                    switch($e->name) {
                        case 'OnManagerWelcomeHome':
                            // set parent ID
                            $parentId = '27';
                            
                            // set the tpl - can also be done in chunks and use chunk name in the param array
                            $rowTpl = 'homeCustom';    
                            $outerTpl = '@CODE: <h3 class="h3pad">Sold Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
                            
                            // set params for Wayfinder - params needs to be an array
                            $params['startId'] = $parentId;
                            $params['level'] = '1';
                            $params['ignoreHidden'] = 'TRUE';
                            $params['rowTpl'] = $rowTpl;
                            $params['outerTpl'] = $outerTpl;
                            
                    		$output .= $modx->runSnippet('Wayfinder', $params);
                    		$output .= '<hr />';
                    
                    		$e->output($output);
                    return;


                    and nothing happens.. what did i do wrong?
                      • 3749
                      • 24,544 Posts
                      You had several unclosed braces. One of the problems with Plugins is that if there is any typo or syntax error it just does nothing. You’ve also got a fair amount of unnecessary code since you don’t have to identify the event or do any decision making in the plugin (since the plugin is only triggered by one event). Try this:


                      <?php
                      
                      //Plugin attached to OnManagerWelcomeHome System Event
                      
                      $e = &$modx->Event;
                      $output ='';
                      // set generic params
                      
                       $rowTpl = 'homeCustom';
                       $params['level'] = '1';
                       $params['ignoreHidden'] = 'TRUE';
                       
                      // set params for Current Properties and call Wayfinder
                                      
                              $outerTpl = '@CODE: <h3 class="h3pad">Current Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
                              
                              $params['startId'] = '4';
                              
                              $params['rowTpl'] = $rowTpl;
                              $params['outerTpl'] = $outerTpl;
                              $output = $modx->runSnippet('Wayfinder', $params);
                              $output .= '<hr />';
                      
                      // set params for Pending Properties and call Wayfinder
                              
                              $outerTpl = '@CODE: <h3 class="h3pad">Pending Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
                              
                              $params['startId'] = '34';
                              
                              $params['rowTpl'] = $rowTpl;
                              $params['outerTpl'] = $outerTpl;
                              $output .= $modx->runSnippet('Wayfinder', $params);
                              $output .= '<hr />';
                      
                      // set params for Sold Properties and call Wayfinder        
                              
                              $outerTpl = '@CODE: <h3 class="h3pad">Sold Properties</h3><ul class="ulpad">[+wf.wrapper+]</ul>';
                              
                              $params['startId'] = '27';
                              
                              $params['rowTpl'] = $rowTpl;
                              $params['outerTpl'] = $outerTpl;
                              
                              $output .= $modx->runSnippet('Wayfinder', $params);
                              $output .= '<hr />';
                      
                              $e->output($output);
                              
                              return;
                      


                      Make sure the plugin is tied to the OnManagerWelcomeHomeEvent.


                        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