[[getResources?
&parents=`[[*id]]`
&limit=`20`
&depth=`0`
&includeTVs=`1`
&processTVs=`1`
&showHidden=`1`
&tpl=`bootstrapBlock`
]][[getResources?
&parents=`[[+id]]`
&limit=`4`
&depth=`0`
&showHidden=`1`
&includeTVs=`1`
&processTVs=`1`
&tpl=`[[+total:is=`1`:then=`oneBootstrapColumn`:else=``]][[+total:is=`3`:then=`twoBootstrapColumn`:else=``]][[+total:is=`4`:then=`threeBootstrapColumn`:else=``]][[+total:is=`5`:then=`fourBootstrapColumn`:else=``]]`
]][[getResources?
&parents=`[[+id]]`
&limit=`1`
&depth=`0`
&includeTVs=`1`
&processTVs=`1`
&includeContent=`1`
&showHidden=`1`
&tplCondition=`template`
&conditionalTpls=`{
"15":"staticContentBlock",
"16":"contactBlock",
"17":"pricingBlock",
"18":"testimonialBlock",
"19":"accordionBlock"
}`
]][[*content]]
Array
(
[tpl] => oneBootstrapColumn
[tplOdd] =>
[tplFirst] =>
[tplLast] =>
[tplWrapper] =>
[wrapIfEmpty] =>
[sortby] => publishedon
[sortbyTV] =>
[sortbyTVType] => string
[sortbyAlias] =>
[sortbyEscaped] => 0
[sortdir] => DESC
[sortdirTV] => DESC
[limit] => 4
[offset] => 0
[tvFilters] =>
[tvFiltersAndDelimiter] => ,
[tvFiltersOrDelimiter] => ||
[depth] => 0
[parents] => 14
[includeContent] =>
[includeTVs] => 1
[includeTVList] =>
[showHidden] => 1
[showUnpublished] =>
[showDeleted] =>
[resources] =>
[processTVs] => 1
[processTVList] =>
[prepareTVs] => 1
[prepareTVList] =>
[tvPrefix] => tv.
[idx] => 1
[first] => 1
[last] => 1
[toPlaceholder] =>
[toSeparatePlaceholders] =>
[debug] =>
[where] =>
[dbCacheFlag] => 0
[context] =>
[tplCondition] =>
[tplOperator] => ==
[conditionalTpls] =>
[odd] => 1
[id] => 15
[type] => document
[contentType] => text/html
[pagetitle] => Testimonial Block
[longtitle] =>
[description] =>
[alias] => testimonial-block
[link_attributes] =>
[published] => 1
[pub_date] => 0
[unpub_date] => 0
[parent] => 14
[isfolder] =>
[introtext] =>
[richtext] => 1
[template] => 15
[menuindex] => 0
[searchable] =>
[cacheable] => 1
[createdby] => 1
[createdon] => 2013-12-27 00:47:17
[editedby] => 1
[editedon] => 2013-12-27 01:52:56
[deleted] =>
[deletedon] => 0
[deletedby] => 0
[publishedon] => 2013-12-27 00:47:00
[publishedby] => 1
[menutitle] =>
[donthit] =>
[privateweb] =>
[privatemgr] =>
[content_dispo] => 0
[hidemenu] =>
[class_key] => modDocument
[context_key] => web
[content_type] => 1
[uri] => new-site/homepage/block-1/testimonial-block.html
[uri_override] => 0
[hide_children_in_tree] => 0
[show_in_tree] => 1
[properties] =>
)
[[getSubResources?
&parents=`[[+id]]`
&limit=`4`
&depth=`0`
&showHidden=`1`
&includeTVs=`1`
&processTVs=`1`
]]
<?php
$totalVar = $modx->getOption('totalVar',$scriptProperties,'subTotal');
$results = $modx->runSnippet('getResources',$scriptProperties);
$total = $modx->getPlaceholder($totalVar);
$tpls = array();
$tpls[1] = 'oneBootstrapColumn';
$tpls[3] = 'twoBootstrapColumn';
$tpls[4] = 'threeBootstrapColumn';
$tpls[5] = 'fourBootstrapColumn';
$scriptProperties['tpl'] = $tpls[$total];
return $modx->runSnippet('getResources',$scriptProperties);
Array
(
[tpl] =>
[tplOdd] =>
[tplFirst] =>
[tplLast] =>
[tplWrapper] =>
[wrapIfEmpty] =>
[sortby] => publishedon
[sortbyTV] =>
[sortbyTVType] => string
[sortbyAlias] =>
[sortbyEscaped] => 0
[sortdir] => DESC
[sortdirTV] => DESC
[limit] => 4
[offset] => 0
[tvFilters] =>
[tvFiltersAndDelimiter] => ,
[tvFiltersOrDelimiter] => ||
[depth] => 0
[parents] => 14
[includeContent] =>
[includeTVs] => 1
[includeTVList] =>
[showHidden] => 1
[showUnpublished] =>
[showDeleted] =>
[resources] =>
[processTVs] => 1
[processTVList] =>
[prepareTVs] => 1
[prepareTVList] =>
[tvPrefix] => tv.
[idx] => 1
[first] => 1
[last] => 1
[toPlaceholder] =>
[toSeparatePlaceholders] =>
[debug] =>
[where] =>
[dbCacheFlag] => 0
[context] =>
[tplCondition] =>
[tplOperator] => ==
[conditionalTpls] =>
[odd] => 1
[id] => 15
[type] => document
[contentType] => text/html
[pagetitle] => Static Content Block
[longtitle] =>
[description] =>
[alias] => static-content-block
[link_attributes] =>
[published] => 1
[pub_date] => 0
[unpub_date] => 0
[parent] => 14
[isfolder] =>
[introtext] =>
[richtext] => 1
[template] => 15
[menuindex] => 0
[searchable] =>
[cacheable] => 1
[createdby] => 1
[createdon] => 2013-12-27 00:47:17
[editedby] => 1
[editedon] => 2013-12-27 15:38:14
[deleted] =>
[deletedon] => 0
[deletedby] => 0
[publishedon] => 2013-12-27 00:47:00
[publishedby] => 1
[menutitle] =>
[donthit] =>
[privateweb] =>
[privatemgr] =>
[content_dispo] => 0
[hidemenu] =>
[class_key] => modDocument
[context_key] => web
[content_type] => 1
[uri] => new-site/homepage/block-1/static-content-block.html
[uri_override] => 0
[hide_children_in_tree] => 0
[show_in_tree] => 1
[properties] =>
)
<?php
$count = 0;
$parent = isset($parent) ? (integer) $parent : 0;
if ($parent > 0) {
$criteria = array(
'parent' => $parent,
'deleted' => false,
'published' => true,
);
$count = $modx->getCount('modResource', $criteria);
}
$modx->setPlaceholder('childCount',$count);
/* return (string) $count; */$modx->setPlaceholder('childCount',(string) $count);
[[getChildCount? &parent=`[[+id]]`]]
[[getResources?
&parents=`[[+id]]`
&limit=`4`
&depth=`0`
&showHidden=`1`
&includeTVs=`1`
&processTVs=`1`
&tpl=`[[!If?
&subject=`[[+childCount]]`
&operator=`EQ`
&operand=`1`
&then=`oneBootstrapColumn`
&else=``
]][[!If?
&subject=`[[+childCount]]`
&operator=`EQ`
&operand=`2`
&then=`twoBootstrapColumn`
&else=``
]][[!If?
&subject=`[[+childCount]]`
&operator=`EQ`
&operand=`2`
&then=`threeBootstrapColumn`
&else=``
]][[!If?
&subject=`[[+childCount]]`
&operator=`GTE`
&operand=`4`
&then=`fourBootstrapColumn`
&else=``
]]`
]]
[tpl] => oneBootstrapColumn
[[getResources?
&parents=`[[+id]]`
&limit=`4`
&depth=`0`
&showHidden=`1`
&includeTVs=`1`
&processTVs=`1`
&tpl=`bootstrapColumn[[getChildCount? &parent=`[[+id]]`]]`
]]I think you are delaying the logic until it is too late by using the ! on your If calls.
Regardless, it seems to me that if you used the original getChildCount snippet which returns a value and named the chunks bootstrapColumn1, bootstrapColumn2, etc. this would be much easier...
[[getResources? &parents=`[[+id]]` &limit=`4` &depth=`0` &showHidden=`1` &includeTVs=`1` &processTVs=`1` &tpl=`bootstrapColumn[[getChildCount? &parent=`[[+id]]`]]` ]]
Array
(
[tpl] => 1
[tplOdd] =>
[tplFirst] =>
[tplLast] =>
[tplWrapper] =>
[wrapIfEmpty] =>
[sortby] => publishedon
[sortbyTV] =>
[sortbyTVType] => string
[sortbyAlias] =>
[sortbyEscaped] => 0
[sortdir] => DESC
[sortdirTV] => DESC
[limit] => 4
[offset] => 0
[tvFilters] =>
[tvFiltersAndDelimiter] => ,
[tvFiltersOrDelimiter] => ||
[depth] => 0
[parents] => 14
[includeContent] =>
[includeTVs] => 1
[includeTVList] =>
[showHidden] => 1
[showUnpublished] =>
[showDeleted] =>
[resources] =>
[processTVs] => 1
[processTVList] =>
[prepareTVs] => 1
[prepareTVList] =>
[tvPrefix] => tv.
[idx] => 1
[first] => 1
[last] => 1
[toPlaceholder] =>
[toSeparatePlaceholders] =>
[debug] =>
[where] =>
[dbCacheFlag] => 0
[context] =>
[tplCondition] =>
[tplOperator] => ==
[conditionalTpls] =>
[odd] => 1
[id] => 15
[type] => document
[contentType] => text/html
[pagetitle] => Static Content Block
[longtitle] =>
[description] =>
[alias] => static-content-block
[link_attributes] =>
[published] => 1
[pub_date] => 0
[unpub_date] => 0
[parent] => 14
[isfolder] =>
[introtext] =>
[richtext] => 1
[template] => 15
[menuindex] => 0
[searchable] =>
[cacheable] => 1
[createdby] => 1
[createdon] => 2013-12-27 00:47:17
[editedby] => 1
[editedon] => 2013-12-27 15:38:14
[deleted] =>
[deletedon] => 0
[deletedby] => 0
[publishedon] => 2013-12-27 00:47:00
[publishedby] => 1
[menutitle] =>
[donthit] =>
[privateweb] =>
[privatemgr] =>
[content_dispo] => 0
[hidemenu] =>
[class_key] => modDocument
[context_key] => web
[content_type] => 1
[uri] => new-site/homepage/block-1/static-content-block.html
[uri_override] => 0
[hide_children_in_tree] => 0
[show_in_tree] => 1
[properties] =>
)