NAVIGATION
This is an old revision of the document!
Requirement: Setting in conf.inc.php
$phpwcms['allow_ext_render'] = 1; //allow including of custom external scripts at frontend rendering
Description:
In the folder /frontend_render/ you can be put down php scripts, which during parsing (simplified: Internal processing) the side to be processed, before the page is delivered to the browser.
All files with the ending *.php are loaded and implemented from the system. The file names are freely selectable (recommended sample: rt_mein_dateiname.php).
The sequence of processing is not assignable without special programming.
The principal item is usually the variable $content [“all”], which holds the content of the side (between <body> and </body>).
Naturally also different system external functions can be implemented.
The file content of a very simple procedure, which writes simply only the text ” That is an unreasonable text” to the end of page at each side:
<?php // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- $content["all"] .= '<p>That is an unreasonable text</p>'; ?>
The file content from a very simple example:
<?php // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- $content["all"] = str_replace('{My_TicTac}', 'My clock ist working very well.', $content["all"]); ?>
The used tag: {My_TicTac}.
Inserted into a cp
{My_TicTac} {DATE_LONG}
the result
My clock ist working very well. Freitag, 23. Januar 2009
at frontend.
The tag is replaced from the result out of the /frontend_render/ file. (The system tag {DATE_LONG} is also in use).
<?php /* ================================================================ dd.mm.yyyy Short descrition Autor: My Name TAG: {My_Tag} Filename: my_tag_replacer.php Folder: /template/inc_script/frontend_render/ Switch: $phpwcms['allow_ext_render'] = 1; (/config/phpwcms/conf.inc.php) Forum: http://forum.phpwcms.org/viewtopic.php?p=xxxxx ================================================================ */ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- if( ! (strpos($content["all"],'{My_Tag:')===false)) { function func_my_specials ($spec1,$spec2) { $my_spec_result = ' ['. $spec2 . ' + '. $spec1 . ']'; return $my_spec_result; } function func_my_tag_replacer ($var1, $var2, $var3 = "no parameter catched") { // My_php_code/source; // e.g. $my_result = ' var1= '. $var1 . func_my_specials ($var3,$var2) . '<br /> var2= '. $var2 . '<br /> var3= '. $var3 . '<br />'. LF; return $my_result; } // {My_Tag:,,} or {My_Tag:} // ----------------------------------------------------- $content["all"] = str_replace('{My_Tag:}', func_my_tag_replacer("Werner","Ulla"), $content["all"]); $content["all"] = preg_replace('/{My_Tag:(.*?),(.*?),(.*?)}/e', 'func_my_tag_replacer("$1","$2","$3")', $content["all"]); // ----------------------------------------------------- } // -----------[ CLOSE ]---------------- ?>
Call in a CP:
{My_Tag:}
{My_Tag: first mad text, second mad text, third mad text}
Frontend output:
var1= Werner [Ulla + no parameter catched] var2= Ulla var3= no parameter catched var1= first mad text [ second mad text + third mad text] var2= second mad text var3= third mad text
Like that it is possible to solve very special problems.
— Knut Heermann (flip-flop) 2009/01/23 15:19