Using the Modifications Directory
By Paul
By Paul
You can create a subdirectory of WSN Knowledge Base named 'modifications', and when you do so all files placed in that directory will be included at the end of start.php. Only PHP files can be included in PHP files, so be sure you don't put any other sort of file in the modifications directory.
Usually you don't want your code to run on every page. To get around this problem, conditionalize it like this:
If you want to make a template variable available for use, take advantage of how all $_GET and $_POST values are available by setting a fake one. Setting
You can also use template functions to call any function you may add to a modifications directory file, or follow a special procedure to add template variables to the objects.
Since these files run at the end of start.php, you can change any values you want to affect how the main body of the page will run. The tradeoff is that since the main body hasn't been processed yet you can't manipulate the final page text or the like here. If you need to do processing in end.php or somewhere else, you'll have to make a mod file with the modifications generator in your admin panel.
Usually you don't want your code to run on every page. To get around this problem, conditionalize it like this:
if (strstr(currenturl(), 'suggest.php?action=addlink'))
{
/* this code only runs on the 'suggest link' page
note that url rewriting should be ignored, currenturl() will contain the non-rewriten version
*/
}
If you want to make a template variable available for use, take advantage of how all $_GET and $_POST values are available by setting a fake one. Setting
makes {SOMETHING} show blah when used in a template (note: remember that if you don't set $_GET['something'] the template var will show literally as {SOMETHING} -- it won't be replaced with a blank value unless you specify one).$_GET['something'] = 'blah';
You can also use template functions to call any function you may add to a modifications directory file, or follow a special procedure to add template variables to the objects.
Since these files run at the end of start.php, you can change any values you want to affect how the main body of the page will run. The tradeoff is that since the main body hasn't been processed yet you can't manipulate the final page text or the like here. If you need to do processing in end.php or somewhere else, you'll have to make a mod file with the modifications generator in your admin panel.
Rating:




5/5 based on 1 vote. The median rating is 5.
Rate this article:
Submitted: 01/02/07 (Edited 11/04/07)
Description: Including new PHP.
Views:
787 views. Averaging 1 per day.
In the most recent 30 day period, there've been 7 views.

Print
E-Mail