Smarty
Smarty is a very powerful PHP template engine. There's lots that can be done in smarty if you just take the time and look.
Smarty lives at http://smarty.php.net, and the documentation is quite extensive and available in multiple languages. Please read it, If you understand this you will get alot more power out of your CMS Made Simple based website.
Determining what variables are available to work with
There's a very convenient plugin in CMS to see the available smarty variables. {get_template_vars}. This plugin simply does a dump of all smarty variables known at that point. To use it, simply place {get_template_vars} near the bottom of a content page, or in a specific function that you need to debug or work with. Try it out.
Dumping arrays and objects
The {get_template_vars} plugin will not recursively dump out the values of Arrays, or Objects. it will just tell you that a variable represents an array or an object. But no fear, there is a way to see what's in them too. You can use some php code inside of smarty. For example {$variablename|print_r} will dump all of the contents of an array or an object, telling you the object members, or the array keys that can be used.
Here's something you could put inside the News summary template to see what you can do:
Code: Select all
{get_template_vars}
{$items|print_r}
Smarty is like a programming language in and of itself (don't fear, it's relatively simple to learn. it's like HTML on steroids). You can place conditionals of any sort in your code, create your own variables, do string and date processing, and a whole bunch of other things. Knowing Smarty language is a smart thing to do when working with CMS.
Smarty conditionals look something like this:
Code: Select all
{if $variable != value}
Some Action or Text to be output
{else}
Something Else
{/if}
It's possible to capture a piece of a smarty template into yet another smarty variable for futher testing, processing, and/or output. This is all in the smarty documentation, but here's an example that I've answered more than once.
To capture the content of a non default CMS content block into a smarty variable to test to see if it is non emtpy, you could do something like this:
Code: Select all
{capture assign="testvar"}{content block="block2"}{/capture}
{if $testvar != '' }
{$testvar}
{/if}