Page 1 of 1

custom RT for german and french quotes

Posted: Wed 14. May 2008, 17:29
by Cipolla
Hi!

a customer of mine wanted all normal "quotes" shown as »french« quotes. There are many quotes in the site!

So i wrote a small hack to replace all quotes with the french or the german version. Maybe this is usefull.

The french version:

Code: Select all

<?php
// ==========================================================
// Replace normal quotes with »french« quotes (V 1.0)
// Klaus Winkler alias [Cipolla] http://www.empics24.de

// Create a file like "french_quotes.php" with this script and put it in the
// frontend_render folder
// ==========================================================

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

// Replace left quotes after a ending tag
  $content["all"] = str_replace('>"','>&raquo;', $content["all"]);
  
  
// Replace left quotes inside text
  $content["all"] = str_replace(' "',' &raquo;', $content["all"]);
  
  
// Replace right quotes before new tag
  $content["all"] = str_replace('"<','&laquo;<', $content["all"]);
  
  
// Replace right quotes inside text
  $content["all"] = str_replace('" ','&laquo; ', $content["all"]);

?>
The german version:

Code: Select all

<?php
// ==========================================================
// Replace normal quotes with „german“ quotes (V 1.0)
// Klaus Winkler alias [Cipolla] http://www.empics24.de

// Create a file like "german_quotes.php" with this script and put it in the
// frontend_render folder
// ==========================================================

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

// Replace left quotes after a ending tag
  $content["all"] = str_replace('>"','>&#132;', $content["all"]);
  
  
// Replace left quotes inside text
  $content["all"] = str_replace(' "',' &#132;', $content["all"]);
  
  
// Replace right quotes before new tag
  $content["all"] = str_replace('"<','&#147;<', $content["all"]);
  
  
// Replace right quotes inside text
  $content["all"] = str_replace('" ','&#147; ', $content["all"]);


?>

Re: Hack for german and french quotes

Posted: Wed 14. May 2008, 18:02
by flip-flop
Very fine work, but it isn´t a hack, it´s a regular custom RT.

Knut :D

Re: Hack for german and french quotes

Posted: Wed 14. May 2008, 18:18
by Cipolla
hello knut,

thanks for the flowers :D
Very fine work, but it isn´t a hack, it´s a regular custom RT.
i thought the definiton of an RT is ReplacementTAG and i did not write a tag like {FRENCH_QUOTE} but only a frontend render script.

Is it better to change the title to custom RT?

Re: Hack for german and french quotes

Posted: Wed 14. May 2008, 18:32
by flip-flop
Is it better to change the title to custom RT?
YES, absolutely.
It is definitely no hack (We named a snippet "hack" if there is a core change). :D

Re: custom RT for german and french quotes

Posted: Wed 21. May 2008, 17:52
by Jensensen
[x]