switchfunction

Date: 13-04-2007 13:11 Views: 2614 Author: Colin Polonowski

Description

Acts as an approximation of the common 'Switch' statement allowing you to carry out different actions depending on the value 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 values and associated response by MonkeyCMS

Syntax

(switchfunction|contentelement|valuesandresponses)

Example

(switchfunction|definition_name|News#getTemplate('Index:News')^^Reviews#getTemplate('Index:Reviews')^^Features#getTemplate('Index:Features'))

The above example switches on 'definition_name' and actions a function depending on the value stored in the definition_name element. For news it uses the getTemplate function to display the Index:News template and each value displays a different template.

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).