Using config files

As well as setting Ditto parameters in the snippet call, you can include a set of parameters in an external PHP file. The file is stored in Ditto's configs folder using a name such as my_setup.config.php, and is included by a parameter like this: &config=`my_setup`.

Config files can make editing easier and less error-prone for large sets of parameters, and provide an opportunity for some pre-processing of the data -- the config file becomes an active part of your script. For instance, if the Request extender is overpowered for the simple job of retrieving a parameter from the URL query string, simply include a line of code in a config file:

http://www.example.com/myPage.html?param_name=62

in config file: $param = $_GET['param_name'];

Every &parameter=`value` pair in a Ditto call has an equivalent $parameter=value statement in the PHP config file. Care is needed with some kinds of parameter that the snippet call would normally transform into an array, possibly a complex one. For instance, the config file equivalent of &orderBy=`pkDate ASC` is

$orderBy = array('parsed'=>array(),'custom'=>array(),
'unparsed'=>'pkDate ASC');

(I don't claim to know how that works - I just lifted it from the snippet call and substituted my values for $orderBy on the right) (View the config file)

Click to sort in ascending or descending order of date

[[Ditto? &parents=`455` &config=`config_demo` ]]

Nunc viverra, ITEM 460 dolor in rutrum vestibulum,

01 November 2004

Vestibulum ante ITEM 461 ipsum primis in faucibus

12 June 2005

Quisque consectetur, ITEM 462 quam sit amet fringilla

16 June 2005

Duis tristique ITEM 463 urna id metus. Maecenas

15 February 2006

Nulla commodo. ITEM 464 Praesent feugiat, dui sit

27 August 2006

Pellentesque habitant ITEM 465 morbi tristique senectus et

09 September 2006

In eu ITEM 466 purus eu mi sollicitudin

02 March 2007

Cras velit. ITEM 467 Integer luctus. In nec

17 June 2007

Praesent ac ITEM 468 ligula. Nam risus tortor,

26 October 2007