We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38520
    • 13 Posts
    Listing Page

    [[!getCategory?&mode=`display`]]
    
    [[!getResources:default=`
    
    Sorry - No Contractors Found for Category.
    
    `? &tpl=`contractorList` &processTVs=`1`&parents=`59` &includeTVs=`1`&limit=`50` &tvPrefix=`` &sortby=`pagetitle` &sortdir=`ASC`&tvFilters=`Category==[[!getCategory]],Category!==''`&showHidden=`true`&hideContainers=`true`&includeTVList=`Address,Category,Contact Person,Email,Fax,Logo,Phone,Website`]]


    getCategory Snippet

    if($mode!='display') {
      $cats = explode('||', $modx->runSnippet('listMyResources',array('parent' => 37, 'list' => 'true')));
    }
    if(isset($_GET['Category']) && $_GET['Category']!='') {
    if($mode=='display') {
          return htmlentities($_GET['Category']);
    } else {
          if(in_array($_GET['Category'], $cats)) {
             return '%'.htmlentities($_GET['Category']).'%';
          } else {
               return 'Please Select a Category.';
          }
    }
    } else {
          return 'Please Select a Category.';
    }


    listMyResources Snippet

    <?php
    $parent = $modx->getOption('parent',$scriptProperties,9);
    $list = $modx->getOption('list',$scriptProperties, 'true');
    $parentObj = $modx->getObject('modResource',$parent);
    if (!($parentObj instanceof modResource)) { return ''; }
    $resArray = $parentObj->getMany('Children');
    $resources = array();
    foreach($resArray as $res) {
      if ($res instanceof modResource) {
        if($res->get('hidemenu')!=1 && $res->get('alias')!='all-contractors') {
           $cat[] = $res->get('pagetitle');
           $resources[] = $res->get('pagetitle') . '==' . $res->get('pagetitle');
        }
      }
    }
    $out = implode("||",$resources);
    $cat = implode("||", $cat);
    if($list == 'true') {
       return $cat;
    } else {
       return $out;
    }


    Description

    URL: http://mca.org/find-a-contractor-results/

    I'm creating a category navigation using weblinks to the results page with the parameter of the category. It then takes the category and makes sure that category exists in the children of my category page (this also creates the multi-select list tv variable on the contractors page)

    These pages take 8-20 seconds to render. Is there a better approach to doing this? Let me know if I can provide any more information.

    Thanks! [ed. note: philip.bennett last edited this post 14 years, 5 months ago.]
      • 19369
      • 1,098 Posts
      1. Change, if you can, all uncached snippet calls to cached snippet calls.
      2. Change, if you can and if you are using them, custom output and input modifiers with the "if" snippet, or make a custom snippet when you need one.
      3. Read this: http://www.markhamstra.com/modx-blog/2011/10/caching-guidelines-for-modx-revolution/
        • 38520
        • 13 Posts
        Thanks microcipcip. I'll see about writing a custom cache script for the results.
          • 25803 ☆ A M B ☆
          • 721 Posts
          Quote from: microcipcip at Apr 17, 2012, 08:14 PM
          2. Change, if you can and if you are using them, custom output and input modifiers with the "if" snippet, or make a custom snippet when you need one.

          Why is that? I've seen other forum members say to use output modifiers instead of If, but that might be just because they are built in. Is there a significant performance advantage to using If?
            • 19369
            • 1,098 Posts