I've just created my first snippet called IsOldBrowser. It's intended as a more advanced IE6NoMore, doing a server-side check for old browsers and to get the client side to generate different HTML based on the result. The snippet is working. It returns a string 'true' when the browser is MSIE<=6 and 'false' for anything else. However, my evaluation of that result is not working. I'm sure someone here can point to my obvious syntactical error:
[[!IsOldBrowser:is=`true` :then=`OLD` :else=`NEW`]]
That's just the most simple form. Replace NEW and OLD with code and chunks for browsers you do and do not support, respectively.
But what's happening is that when that is called it just displays the value 'true' or 'false'. The PHP does this:
return $isOld ? 'true' : 'false';
I don't want to display that literal. I want to evaluate that result and display something else.
Another issue is that the snippet is executed twice on every page refresh. It's being called from the resource template - only one call in there of course. I see this in the Log report.
I'm trying to learn proper syntax and snippet building as well as completing this contrived task. When complete I'll post this for others. It's value over IE6NoMore is that it's not just focused on IE, and it's not supposed to just return content (which unfortunately it's doing) but to allow the manager to determine the content, which I believe is more elegant. IE6NoMore renders a chunk of choice - this simply returns the result of some logic and then lets the UI decide what to do with that information. It's just another way of looking at the solution.
Thanks!