{{[+language+]_side_menu}}If I put [+language+] on the page outside the {{ }} it will show it’s value ("de" in my case). So it should be working. But it doesn’t output anything when placed inside the chunk like stated above.The reason it doesn’t work when placed inside the chunk is because of the way the document parser works in Evo. Unfortunately, chunks get parsed before the placeholders.
if (array_key_exists('language', $modx->placeholders)) {
return $modx->getChunk($modx->placeholders['language'] . '_side_menu');
} else {
return '';
}
<?php
if (array_key_exists('language', $modx->placeholders)) {
return $modx->getChunk('[*season*]'.'Nav_'.$modx->placeholders['language']);
} else {
return '';
}
?>
If I may extend this question. I’m trying to do something similar.
I created a snippet with the original code and including a TV to generate the complete name of the chunk.
<?php if (array_key_exists('language', $modx->placeholders)) { return $modx->getChunk('[*season*]'.'Nav_'.$modx->placeholders['language']); } else { return ''; } ?>
[!MySnippet? &tvName=`[*season*] !]
return $modx->getChunk($tvName . 'Nav_'.$modx->placeholders['language']);
I would like that; I was just thinking of adding such a functionality to an internal intranet site I’ll be working on; no need for an intranet site to be boring, and changing the stylesheet in the manner of CSS Zen Garden according to the seasons would be a nice touch.
<?php
/* function seasion() -- returns the name of the current season */
function season() {
$limits=array('/12/21'=>'Winter', '/09/21'=>'Fall', '/06/21'=>'Summer', '/03/21'=>'Spring', '/01/01'=>'Winter');
$adate = date("M d Y"); //set $adate to today
foreach ($limits AS $key => $value) {
$limit=date("Y").$key;
if (strtotime($adate)>=strtotime($limit)) {
return $value;
}
}
}
switch( season() ) {
case "Spring": {
$output = $modx->getChunk("spring");
break;
}
case "Summer": {
$output = $modx->getChunk("summer");
break;
}
case "Fall": {
$output = $modx->getChunk("fall");
break;
}
case "Winter": {
$output = $modx->getChunk("winter");
break;
}
default:
echo "<h1> Sorry, there's an Error in Season Specials</h1>";
echo "<h1> Please notify the webmaster</h1>";
}
return $output;
?>