Use of scripts in templates
From phpCMS
[edit] How to insert scripts into a template
Normally it is not possible to insert a script into a template. But sometimes it would be useful. Perhaps you need the output of the script on every page of your site without inserting the script on every content page.
One solution is to write a little plugin, which includes the script for you.
This sounds more complicated, than it is. There's only a plugin with one line needed:
<?php $PageContent->SCRIPT_EXAMPLE[0] = '$home/script1.php'; ?>
or alternatively (note the absence of [0])
<?php
$PageContent->SCRIPT_EXAMPLE = array('$home/script1.php');
?>
Remember: No spaces or empty lines after the closing "?>", line ending have to be *NIX style. i.e. "LF" only!
In this example the plugin will be saved as plugin1.php and then inserted at the beginning of the template.
{PLUGIN FILE="$home/plugs/plugin1.php" TYPE="STATIC"}
Now you only need to insert {SCRIPT_EXAMPLE} in your template to insert the result of the called script.
Remark:
The plugin can always be inserted as STATIC, because the script will be executed after the replacement of the placeholder.
(Original text by Ignatius, extended by Tobias Dönz(de), changed because a hint by Martin Jahn)
Main Page: Tutorials MainPage | Top Page: MiniHowTos MainPage
Diese Seite in anderen Sprachen: Deutsch

