Strict Standards: Declaration of action_plugin_dlcount::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/dlcount/action.php on line 14

Strict Standards: Declaration of action_plugin_indexmenu::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/indexmenu/action.php on line 169

Strict Standards: Declaration of action_plugin_ipban::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/ipban/action.php on line 67

Strict Standards: Declaration of action_plugin_loglog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/loglog/action.php on line 82

Strict Standards: Declaration of action_plugin_navi::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/navi/action.php on line 46

Strict Standards: Declaration of action_plugin_uparrow::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/uparrow/action.php on line 69

Strict Standards: Declaration of action_plugin_userspagecreate::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/userspagecreate/action.php on line 97

Strict Standards: Declaration of cache_instructions::retrieveCache() should be compatible with cache::retrieveCache($clean = true) in /home/www/wiki/inc/cache.php on line 289

Warning: Cannot modify header information - headers already sent by (output started at /home/www/wiki/lib/plugins/dlcount/action.php:14) in /home/www/wiki/inc/auth.php on line 312

Strict Standards: Only variables should be passed by reference in /home/www/wiki/doku.php on line 71

Warning: Cannot modify header information - headers already sent by (output started at /home/www/wiki/lib/plugins/dlcount/action.php:14) in /home/www/wiki/inc/actions.php on line 154
/frontend_render/ [phpwcms-HowTo:wiki]

Strict Standards: Declaration of syntax_plugin_code::render() should be compatible with DokuWiki_Syntax_Plugin::render($format, &$renderer, $data) in /home/www/wiki/lib/plugins/code/syntax.php on line 41

Strict Standards: Declaration of syntax_plugin_tip::render() should be compatible with DokuWiki_Syntax_Plugin::render($format, &$renderer, $data) in /home/www/wiki/lib/plugins/tip/syntax.php on line 38

/frontend_render/

Requirement: <$phpwcms['allow_ext_render'] = 1;/config/phpwcms/conf.inc.php


Description:

Into the folder template/inc_script/frontend_render/ you can install own php scripts, which are processed while parsing (simplified: Internal processing) the site, before the page is delivered to the browser.

All files ending with *.php are loaded and implemented by 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 is holding the content of the page (between <body> and </body>).


Naturally also different system external functions can be implemented.


Folder: template/inc_script/frontend_render/

Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_render'] = 1;


Important

In all files in these folders should be for security reasons at the beginning of each file, the following sequence:

<?php
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
...
...


Single example:

The file content of a very simple procedure, which simply will write only the text ” That is an unreasonable text” to the end of page at each page:

<?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>';
 
?>

Example 1:

The file content of 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 by the result of the /frontend_render/ file. (The system tag {DATE_LONG} is in use also).

Example 2:

rt_my_tag.php

<?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

This way it is possible to solve very special problems.

Knut Heermann (flip-flop) 2009/01/23 15:19


Processing order of the files in /frontend_render/

If you have more than one file within frontend_render and the results of the routines are depending on each other, a fundamental problem of the processing sequence is arising.
We can´t determinethe processing sequence of the files in this folder directly.

Solution 01

Explained by the example NAV_HORIZ_DD and the FE language switch.

–> Forum

  1. We use a custom navigation like {NAV_HORIZ_DD:xx,yy}
  2. We use the custom frontend_render language switch.

If the frontend_render language switch is processed before the NAV_HORIZ_DD script, all language tags in this navigation file are not processed.

[de]Das Haus[/de][en]The Hotel[/en][de]Urlaub & Familie[/de][en]Holidays & Family[/en]

The simplest solution:
Shift the concerning files into another folder and define the correct processing order of the these files with the help of a third file.

  1. Create a folder e.g. /frontend_render/special
  2. Move the two files rt_nav_horiz_drop_down.php and lang_replace.php from /frontend_render/ into /frontend_render/special/
  3. Create a file e.g. processing_order.php in /frontend_render/

processing_order.php

<?php
 
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
 
// Specifies the sequence of processing files
include ('special/rt_nav_horiz_drop_down.php');  // processing first
include ('special/lang_replace.php');            // processing second
 
?>


Solution 02

To optimize the script's runtime on your server you can put the content of all /frontend_render/* files in the right order into one file e.g. called /frontend_render/master.php. Disable all other files of this folder by extending the suffix like e.g. *.php_

Thats it, we have determined the processing order. :-D
(You can do this with all other php snippets in /frontend_render/ if you have similar problems).


Short link overview

english/phpwcms_replacer_rts/frontend_render.txt · Last modified: 2012/12/13 13:03 by Knut Heermann (flip-flop)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0

Strict Standards: Only variables should be passed by reference in /home/www/wiki/doku.php on line 79