Latest Register Log In

+ Advanced Search

Unique Settings and Switches For a Template Set

Unique Settings and Switches For a Template Set
By
11/05/07 (Edited 03/10/14)

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
$flags['forcestyle'] = '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. You can accomplish this with an installphp.wsn file in the template set. For example:
$settings->linkcols = 1;
$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). You can also perform more complex tasks, like changing the default language or removing all but one language, in your installphp.wsn. In fact, when deploying internally you can use it to automate the whole process of customizations you do when you install a new site.




Description Changing settings, switches and other things for one template set without changing for others.
Rating
Views 1215 views. Averaging 0 views per day.
Similar Listings