[[!getResources?
&sortby=``
&parents=`[[UltimateParent?]]`
&includeTVs=`1`
&processTVs=`1`
&tvPrefix=``
&tpl=`tpl.gr.section.news.box`
[[!If?
&subject=`[[!getUrlParam? &name=`category` &int=`0`]]`
&operator=`notempty`
&then=`&tvFilters=`tv.content.news.cat==[[!getUrlParam? &name=`category` &int=`0`]]``
&else=``
]]
&debug=`1`
]]This question has been answered by BobRay. See the first response.
[[!getResources?
&sortby=``
&parents=`[[UltimateParent?]]`
&includeTVs=`1`
&processTVs=`1`
&tvPrefix=``
&tpl=`tpl.gr.section.news.boxa`
[[!If?
&subject=`[[!getUrlParam? &name=`category` &int=`0`]]`
&operator=`isempty`
&then=``
&else=`&tvFilters=`tv.content.news.cat==[[!getUrlParam? &name=`category` &int=`0`]]``
]]
&debug=`1`
]][[!getResources:if=`[[!getUrlParam? &name=`category` &int=`0`]]`:notempty=` [[!getResources? &sortby=`` &parents=`[[UltimateParent?]]` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &tpl=`tpl.gr.section.news.box` &tvFilters=`tv.content.news.cat==[[!getUrlParam? &name=`category` &int=`0`]]` ]] ` ]] [[!getResources:if=`[[!getUrlParam? &name=`category` &int=`0`]]`:isempty=` [[!getResources? &sortby=`` &parents=`[[UltimateParent?]]` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &tpl=`tpl.gr.section.news.box` ]]
Would this code effect performance?
Would this code effect performance?
yes, this would run every snippet-call on this construct, everytime the page is loaded.
back to the drawing board.
<?php
$category = isset($_GET['category']) && (!empty($_GET['category']))
? $_GET['category']
: '';
$fields = array(
'includeTVs' => true,
'processTVs' => true,
'tvPrefix' => '',
'tpl' => 'tpl.gr.section.news.box',
);
$fields['parent'] = $modx->runSnippet('UltimateParent');
if ($category) {
$fields['tvFilters'] = 'tv.content.news.cat==' . $category;
}
return $modx->runSnippet(getResources, $fields);return $modx->runSnippet('getResources',$fields);