so that means attempts are made to process them on every pass
practically - this mean the default 10 times?
Don’t place invalid tags in your content, or at least have the insight to make them all non-cacheable.
I’ll be concrete with one example:
’members’ are extended modUser with a bunch of tables and relationships..
Member can have multiple professions, lets say up to three, for the example (musician, programmer and street-cleaner - a perfectly normal situation in our days...). ofource, he also just be a ’CEO’...
ok, seriously - the listMembers snippet gets all this data (xpdo) then creates chronological-placeholders (attached below) and then parsing via getChunk(’memberTpl’).
’memberTpl’ must contain tag placeholder for all three potential professions, if they exist or not.
So, as you suggest - to resolve the performance issue for that situation, I must create empty placeholders for the non-existing professions..
mm... not so elegant (although seems like the simplest way). can I somehow force single-pass over tags parsing?
In general - I’m now doing many performance enhancement on this application (revo based social-network), and I see my biggest hogs are always placeholders and filters related (:userinfo, :memberinfo, :resourceinfo -- all i’m getting rid of now..)
As the application is still growing (design and functionality-wise), it’s a game between better performance and simpler changes. seems I’ll play on the game..
I "allowed" myself to use setPlaceholders a lot (much more then precise getChunk(’tpl’,array(specific)), as I saw you guys fill up the placeholders too. There’s undoubtedly a place for performance improvements on that part.
or at least have the insight to make them all non-cacheable
What do you mean?
Something like this would still not resolve it.
Actually - modx tag parsing has nothing to do with the [[if, it’ll parse everything in any case...
[[!if? &subject=`[[+[[+userId]].MemberSkillGroups.3.skillId]]` &operator=`notempty`
&then=`
<img class="icon tiny" src="[[++base_url]]assets/members/skillgroups/[[+[[+userId]].MemberSkillGroups.3.skillId]].png" alt="icon "/>
<h2>[[+[[+userId]].MemberSkillGroups.3.Professions]]</h2>
`
]]
ATTACHMENT:
/* same as toPlaceholders, but naming in 1.2.3.4.. order, and not PK-based (as toPlaceholderS) */
function chronologicalPlaceholder($parentObj,$alias,$prefix) {
global $modx;
if (!isset($prefix)) {$prefix = $alias;} // default to use alias as placeholder prefix
$childs = $parentObj->getMany($alias); // get all children
sort($childs); // change array's keys to 0,1,2,etc...
array_unshift($childs,array()); // add empty one, simply so the numbering will start from 1 and not 0
$modx->toPlaceholders($childs,$prefix,"."); // generate modx placeholders for templates
return $childs; // return the array, needed for recursive placeholder (grandchildren relationship or more)
}