-
MODX Staff
- 2,502 Posts
You have a few things going on here not the least of which is a placeholder being the subject of the If call? What is the [[+cat]]? I also don’t know (as I haven’t tested it but what happens once those Wayfinder calls get cached? You could optionally put the If snippet inside wayfinder call and swap out the paramaters based on result.
If you want to use a snippet you are going to have to evaluate the output/value of the [[+cat]] placeholder. You’ll want something like the following (Warning I am not a dev):
<?php
$cat = $modx->getPlaceholder('cat');
if(!$cat || $cat == ''){
$params = array('displayStart'=> 'true', 'hereId'=> $cat, 'startId'=> $modx->runSnippet('UltimateParent',array('id'=>$cat, 'top'=>'108'));
}
else{
$params = array('startId'=>'108', 'level'=>'1');
}
$o = $modx->runSnippet('Wayfinder', $params);
return $o;
?>
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
MODX Staff
- 2,502 Posts
You could possibly use output filters inside the Wayfinder call but they are not necessarily going to be faster than one snippet. You’d have to try it to see.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
-
MODX Staff
- 2,502 Posts
From what I recall sending the Wayfinder calls out as output won’t get parsed. I could be wrong there but my method yields the same result and uses the API directly vs. the parser. It should be faster.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub