switchfunctionsubstring

Date: 03-05-2007 10:09 Views: 3227 Author: Colin Polonowski

Description

Acts as an approximation of the common 'Switch' statement allowing you to carry out different actions depending on a substring within a specified content element. You can call PHP functions or standard MonkeyCMS functions or just output a string of text.

There are two parameters:

  1. contentelement - the element you wish to 'switch' against
  2. valuesandresponses - the possible substrings and associated response by MonkeyCMS

Syntax

(switchfunctionsubstring|contentelement|substringsandresponses)

Example

(switchfunctionsubstring|title|data#getTemplate('DataTemplate')^^computer#getTemplate('ComputerTemplate')^^files#getTemplate('FileTemplate'))

The above example switches on 'title' and actions a function if a particular substring is contained within that element.

You could replace the getTemplate() function with a simple string of text or HTML or you can use any MonkeyCMS function. Each value-response pairing is split by two hats (^^) and the pairing itself is split by #. In order for MonkeyCMS functions to be used the usual pipe (|) is replaced with two asterix (**), for example to use the function (template|TemplateName) you'd specify (template**TemplateName).