<?php $thisid = $modx->documentIdentifier; $output =''; $tvcontent = $modx->getTemplateVarOutput(array("container"), $docid=$thisid); if($tvcontent['container'] ==''){ $output .='<h1>[*longtitle*]</h1>[*content*]'; }else{ $output .='[[Ditto]]'; } return $output; ?>
<?php $if = isset( $if ) ? $if : ""; $is = isset( $is ) ? $is : ""; $then = isset( $then ) ? $then : ""; $else = isset( $else ) ? $else : ""; $output =''; if($if == $is) { $output = $then; } else { $output = $else; } return $output; ?>
<?php $output = ''; $check = $modx->documentObject['content']; $current = $modx->documentObject['id']; $snippetID = isset( $snippetID ) ? $snippetID : $current; $usesnippet = isset( $usesnippet ) ? $usesnippet : "0"; //1 -first snippet option [!noContent?usesnippet=`1`!] $dittoParam['parents'] = int($snippetID); $dittoParam['display'] = '10'; $ditto = $modx->runSnippet('Ditto', $dittoParam); //2 -second snippet option [!noContent?usesnippet=`2`!] $wfParam['startId'] = int($snippetID); $wayfinder = $modx->runSnippet('Wayfinder', $wfParam); if ($check == '' && $usesnippet == "1") { $output = $ditto; } elseif ($check == '' && $usesnippet == "2") { $output = $wayfinder; } else { $output = '<h1>' . $modx->documentObject['longtitle'] . '</h1>' . $check; } return $output; ?>
I’ve found a solution for the moment. I am still interested in a dynamic snippet for if statements, a snippet that emulate PHx behaviour without the 100kb limit. It might be very useful for the community, for example to create a unique template that change depending on a variable.
The ideal snippet should have the variables in the call so that I can use it multiple times. Like this [[snippet? &if=`[*container*]` &is=`` &then=`<h1>[*longtitle*]</h1>{{slideshow}}[*content*]` &else=`[!ditto!]`]]
I will try to create a snippet when I have time. Thanks everybody for the help!
<? if ($if == $is) { return $then; } else { return $else; } ?>
<?php return empty($if)? $then : $else; ?>
<? if ($if == $is) { return $then; } else { return $else; } ?>
[[snippetName? &if=`[*templateVariable*]` &is=`value1` &then=`[[Ditto? &parents=`1`]]` &else=`[[Ditto? &parents=`2`]]` ]]
<div clas
<div class="ditto_item" id="ditto_item_21"> <h3 class="ditto_pageTitle"><a href="index.php?id=21">item01</a></h3> <div class="ditto_documentInfo">by <strong>Default admin account</strong> on 16-giu-10 16:50</div> <div class="ditto_introText"></div> </div> <div class="ditto_item" id="ditto_item_20"> <h3 class="ditto_pageTitle"><a href="index.php?id=20">item02</a></h3> <div class="ditto_documentInfo">by <strong>Default admin account</strong> on 16-giu-10 16:50</div> <div class="ditto_introText"></div> </div>