In my template I need to load chunks based on what ID/page I'm on.
I need to say:
when id = 1 then show chunk main-home
when id = 4 then show chunk main-pizza
else show chunk main-default
The problem is I can't load a snippet(ditto) into a snippet.
Maybe this can be done some other way like PHx?! (not directly in the snippet)?
There are many snippets available but I'm always struggling with this.
I need a standard for this which works.
I hate to do this by a dropdown TV
Evolution user, I like the back-end speed and simplicity

I guess it does work when I call my Ditto uncached!
For peoples who might want to use this:
My call:
[!main-switch?
&parent_ids=`1,4`
&chunk_names=`main-home,main-pizza`
&def_chunk_name=`main-default`
!]
My snippet:
<?php
// set the default ids of the top level parent containers
$default_parent_ids = array();
// set the default names of the chunks to display
// based on the same order as the $parent_ids
$default_chunk_names = array();
// set the overall default chunk name
$default_chunk_name = isset($def_chunk_name) ? $def_chunk_name : '';
// ===== end setup ===== //
$parent_ids = isset($parent_ids) ? explode(',',$parent_ids) : $default_parent_ids;
$chunk_names = isset($chunk_names) ? explode(',',$chunk_names) : $default_chunk_names;
if(count($parent_ids) > 0 && count($chunk_names) > 0){
$uparent = $modx->runSnippet('UltimateParent');
$check_array = array($modx->documentObject['id'],$modx->documentObject['parent'],$uparent);
for($x=0; $x < count($parent_ids); $x++){
if(in_array($parent_ids[$x],$check_array)){
$print_chunk = $chunk_names[$x];
}
}
// if $print_chunk is empty set to overall default
if($print_chunk ==''){
$print_chunk = $default_chunk_name;
}
}
return $modx->getChunk($print_chunk);
?>
Main-home chunk has this dittocall:
[[Ditto?
&parents=`9`
&total=`3`
&showPublishedOnly=`1`
&orderBy=`menuindex ASC`
&noResults=`No news..`
&tpl=`news-ditto`
]]
Evolution user, I like the back-end speed and simplicity
