I want to wrap a chunk, nested inside another chunk, basically a side bar, with an if statement to check for a page or document name.
If is this document, show that side bar, if is that document show that side bar, etc.
100% visual designer here so sorry and thanks in advance.
Carl
In Revo you can either use the If extra or an output modifier:
In your template:
[[*id:is=`resource id`:then=`[[$chunk1]]`:else=`[[$chunk2]]`]]
Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
Awesome, thank you.
What if I wanted to check for multiple id's like an elseif?
-
☆ A M B ☆
- 894 Posts
You can use or with output modifiers as well
[[*id:eq=`resource id`:or:eq=`resource 2 id`:then=``:else=``]]
You can add more or's to this as well just be careful since output modifiers can cause performance issues.
you can also create a checkbox-TV with all possible chunks for your sidebar with input-options:
Chunk A==[[$chunk_a]]||Chunk B==[[$chunk_b]]||Chunk C==[[$chunk_c]]||Chunk D==[[$chunk_d]]
and put this TV-tag into your chunk/template
Than you need just do check the checkboxes to add chunks to your sidebar.
You can also create a pretty simple snippet to grab the chunks, which would be faster:
I'm assuming that you only want one chunk in the sidebar, but this could be modified to get multiple chunks:
[[!GetSidebarChunk? &pageId=`[[*id]]` ]]
<?php
/* GetSidebarChunk snippet */
/* returns the contents of the appropriate chunk based on the page ID */
$output = "";
switch ($scriptProperties['pageId']) {
case 12:
case 14:
$output = $modx->getChunk('SomeChunk');
break;
case 23:
$output = $modx->getChunk('SomeOtherChunk');
break;
default:
$output = $modx->getChunk('DefaultChunk');
break;
}
return $output;
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html