NAVIGATION
This is an old revision of the document!
Have a look: Templates
One way to use a file on the server as a template. Thus, the editing of the template via CMS is shifted to an FTP enabled editor.
Condition: → /config/phpwcms/conf.inc.php
In the directory template/inc_script/frontend_init/ we store the file template_inject01.php with the following content:
<?php /********************************************************************************************* * Backend Template main replace * Replaces the the main template with the contents of the * file "template/inc_script/template/main01.php". * KH 07.01.2010 **********************************************************************************************/ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- if ($block['maintext'] == 'main01.php') $block['maintext'] = file_get_contents(PHPWCMS_TEMPLATE.'/inc_script/template/'.$block['maintext']); ?>
In this example the template file is called main01.php and is stored in the directory template/inc_script/template/.
The script looks in the template block “main:” whether the text main01.php is entered there. (And only this one).
In main01.php wird der Quelltext für “Haupt:” abgelegt ohne den öffnenden/schließenden PHP-Tag <?php .... ?>.
In main01.php the source code for “main:” is passed without the opening/closing PHP tag <?php .... ?>.
<note important> To speed up the query the presence of tags is not tested in the “main:” field.
This procedure should only be used in the development phase!! </note>
Normally these fields aren't useful any more, because these fields with the layout variant rendering: “custom” will not be queried.
With a small replacer it is however possible to merge these input fields into the field “main:”.
We set the tags into the postions where the contents of these fields in the template “main:” will be merged.
<note> It may happen that some functions in the alternative fields will be processed by the system before being inserted into “main”. If so, please place the instructions directly into the “main:” field. Alternatively, the RT (SHOW_CONTENT :…..} could be used. </note>
Condition: → /config/phpwcms/conf.inc.php
Please insert the file template_inject02.php with the following content into the folder template/inc_script/frontend_init/ :
<?php /********************************************************************************************* * Backend Template field replacer * Replaces the placeholder {HEADERTEMP}, {FOOTERTEMP}, {LEFTTEMP}, {RIGHTTEMP} in "main" * with the contents of the fields "header", "footer", "left", "right". * KH 07.01.2010 **********************************************************************************************/ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- if (!empty($block['headertext']) ) $block['maintext'] = str_replace('{HEADERTEMP}', $block['headertext'],$block['maintext']); if (!empty($block['righttext'])) $block['maintext'] = str_replace('{RIGHTTEMP}' , $block['righttext'], $block['maintext']); if (!empty($block['footertext'])) $block['maintext'] = str_replace('{FOOTERTEMP}', $block['footertext'],$block['maintext']); if (!empty($block['lefttext'])) $block['maintext'] = str_replace('{LEFTTEMP}' , $block['lefttext'], $block['maintext']); ?>
The self-defined “custom” blocks are addressed with (e.g. block name “BOX01” in page layout → blocks → custom:)
$block['customblock_BOX01']
<note important> To speed up the query the presence of tags is not tested in the “main:” field. It is your responsibility to use only tags, although the corresponding content is available in alternative fields. </note>
Both methods can be combined.