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.]