Page 1 of 1

Is there a simple placeholder functionality?

Posted: Fri 16. Dec 2005, 13:42
by lupo
On my website are references to names or email addresses. Unfortunately, these data are changing often and it's annoying to search for all occurances and change them.
Thus, I would like to work with placeholders and use just a symbolic name in the article text like e.g.
{email_address(Peter Muster)}
Is there a simple solution for that?

btw.: thanks to all the persons that give so much answers in this forum!

----

Auf meiner Website sind Namen und eMail Adressen von Personen erwähnt. Leider wechseln diese Daten oft und es ist mühsam, diese in allen Seiten zu suchen und anzupassen.
Ich würde deshalb gerne mit Platzhaltern arbeiten, so dass im Artikeltext nur der symbolische Name, z.B.
{email_address:(Peter Muster)}
erscheint. Gibt es hier eine einfache Lösung?

An dieser Stelle übrigens mal ein herzliches Dankeschön für diejenigen, die fast keine Frage in diesem Forum unbeantwortet lassen!

Posted: Fri 16. Dec 2005, 16:29
by lupo
Neelix solved my problem:

A little script in ...\phpwcms_template\inc_script\frontend_render\ does the work (qtrans.php)

Code: Select all

<?php

/* quick trans: v0.002 (original by neelix) */ 
function getQTrans($sWhat="") 
{ 
/* 
   example: {QTrans:mail_abc} => a.bc@luspix.ch 
*/
 
   $aRealAddi=array('mail_abc'  => 'a.bc@luspix.ch',
                    'mail_def'  => 'de.f@aargaufire.ch',
                    'mail_hij'  => 'hij@fwbrugg.ch'); 

   return $aRealAddi[$sWhat]; 
} 

if (!strpos($content['all'],'{QTrans:')===false) 
{ 
   $content['all'] = preg_replace('/\{QTrans:(\w+)\}/ie', 'getQTrans("$1")', $content['all']); 
}
?>
Thanks, Neelix! :D

Posted: Sat 17. Dec 2005, 05:18
by Pappnase
hallo

wäre es nicht sogar möglich auf ein kontaktformular zu verlinken. ;-) man müßte zwar für jede mail addy in forumalr anlegen aber das wäre ja nicht das schlimmste! :-)