By Paul
Sometimes you'll want particular switches to be off in one template set and on in another, or particular settings to be changed. You can do this by placing a forceswitches.php file in the template set. Example:
<?php
$settings->stylesheet = 'somestyle'; // force styles/somestyle.css to be used
$switches['onlineusers'] = 0; // turn off online users
$switches['maintoplist'] = 0; // turn off the index toplist
$settings->catcols = 3; // use three columns of categories
$settings->linkcols = 0; // don't use columns for articles
?>
$settings->stylesheet = 'somestyle'; // force styles/somestyle.css to be used
$switches['onlineusers'] = 0; // turn off online users
$switches['maintoplist'] = 0; // turn off the index toplist
$settings->catcols = 3; // use three columns of categories
$settings->linkcols = 0; // don't use columns for articles
?>
The changes you specify in the file will be in effect whenever the template set is being used, and will fall out of effect whenever a different template set is used.
Now, suppose you want the PHP to run only at the time of installation, still allowing people to change their settings later. Since 4.2.0 you can accomplish this with an installphp.wsn file in the template set. For example:
$settings->linkcols = 1;
$settings->update('linkcols');
$settings->update('linkcols');
It'll be called once during installation, then deleted. (Note: Don't use PHP opening/closing tags, as this will be loaded as text and run with eval() in order to prevent it from accidentally being run multiple times).

Print
Rate
E-Mail