This is some kind of evolved
chunkIf (have a look at it in the extensions section:
http://modxcms.com/extras/package/69) by dflock (Duncan Lock).
The original chunkIf snippet will have a look at a TV and depending on the fact if it is empty or not display one chunk or another. Usually you’ll be using a checkbox and if it is checked chunk #1 will appear. If not chunk #2.
For a recent project I needed something more advanced, so I decided to create something more versatile.
Welcome to
chunkWhatever.
chunkWhatever will return one or more chunks depending on requirements you have set inside the snippet call.
Usage: Create a TV called "test" (use a group of radio buttons and set them to be deliminated by double pipes, ||) Then add chunkWhatever to a document. Depending on which of the radiobuttons is active (checked), you can now display a specific chunk on this page.
[[chunkWhatever?
&tv=`test`
&choices=`yes::yesChunk||no::noChunk||maybe::maybeChunk`
&debugging=`screen`
&delimiter=`||`
&published=`1`
]]
Depending on the value(s) of the TV you can now output one or more chunks. If you are using a set of checkboxes, you can even display more that one chunk at once.
I use this one to give my editors the power to switch certain page elements ON or OFF.
Additional feature: "Detailed debugging"
* chunkWhatever will tell you, if a chunk or TV doesn’t exist.
* You can send debugging informaiton to the screen or use an html comment instead (this one needs some improvement...).
That’s it. For more information, you should study the snippet code. It will tell you all about the parameters and the general usage.
Disclaimer: As far as I can see this snippet works as expected. I have tested several scenarios and different TVs with and without values. It behaved very well and I’m quite pleased. However, this one is only a few hours old and still
BETA. Test this one on your own risk. If you find any problem, please contact me. Either by pm or email (you will find my adress inside the source).
Have fun,
pepebe