Gästebuch_template

Bitte alle templatebezogenen Beiträge in diesem Forum veröffentlichen.
User avatar
Marceau
Posts: 201
Joined: Sun 23. Apr 2006, 01:52
Location: Leipzig, Germany
Contact:

Re: Gästebuch_template

Post by Marceau »

Nee daran lag es leider auch nicht.
die <br />'s werden gelöscht... hab das mal mit nem str_replace getestet... :/
There are 10 types of people in the world: Those who understand binary and those who don't
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: Gästebuch_template

Post by flip-flop »

Hallo,

das ist nicht ganz so einfach, da die Renderreihenfolge [PHP] und Template genauer betrachtet werden muss. Der Template Renderer schmeißt alle HTML-Tags raus.
Anderseits generiert er kein <br> in dem innerhalb von [PHP] angesteuerten Tag {MSG} (Funktion: nl2br ( string $string [, bool $is_xhtml= true ] ))

Also muss die ganze Sache ausgetrickst werden. Das sollte so funktionieren (nicht getestet).

Template

Code: Select all

[MSG]
<p>
[PHP]if('{EMAIL}' == 'xxx at xxx dot de') { echo '<!--MSG_OBEN//-->'; }[/PHP]
{MSG}
[PHP]if('{EMAIL}' == 'xxx at xxx dot de') { echo '<!--MSG_UNTEN//-->'; }[/PHP]
</p>
[/MSG]
Einfacher Ersetzer der zu vor eingefügten Marken <!--MSG_OBEN//--> ... <!--MSG_UNTEN//-->
In /frontend_init/my_trigger.php

Code: Select all

<?php
 
// http://forum.phpwcms.org/viewtopic.php?p=107107#p107107
/* ------------------------------------------------------------------
function cp_trigger_function_name($param1, & $param2) {
   if($param2['acontent_type'] == 14) { // 14 is CP WYSIWYG
      $param1 = do_this_or_that($param2['acontent_id']);
   }
   return $param1;
}
 
* cp_trigger_function_name - the unique function name
* $param1 - holds the content part html source on which you can parse or do custom processing
* $param2 - is a reference to an array which holds content part values like ID, dates and other values - see db table phpwcms_articlecontent
 
Always return $param1;
*/
// ------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------
 
 
function CP_GUESTBOOK_wrap_MSG($text, & $data) {
   if($data['acontent_type'] == 18) { // 29 is CP guestbook
    $text = preg_replace('/\<!--MSG_OBEN\/\/--\>(.*?)\<!--MSG_UNTEN\/\/--\>/is', '<span style="color:#D48F08">$1</span>', $text);
   }
return $text;
}

register_cp_trigger('CP_GUESTBOOK_wrap_MSG');

?>
Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
Post Reply