create a new file... phpwcms_template/inc_script/frontend_render/glossary.php
Code: Select all
<?
function glossary( $string )
{
$string = StrPrep($string);
$harray = explode(' ',$string);
$c = count($harray);
for( $i = 0; $i <= $c; $i++)
{
$tip = swapword($harray[$i]);
if (strtolower($tip) != strtolower($harray[$i])) {
$harray[$i] = '{TOOLTIP:'.$harray[$i].','.$tip.'}';
}
}
$string = implode(' ',$harray);
$string = StrFix($string);
return $string;
}
function swapword ($string)
{
$lowstring = strtolower($string);
switch($lowstring)
{
//start of glossary terms
case "bumble": return "To move, act, or proceed clumsily";
case "pickle": return "a sauce made from vegetables or fruit which have been preserved in a vinegar sauce or salty water";
case "pebble": return "A small stone, especially one worn smooth by erosion";
//case "design": return "something I do :)";
//end of glossary
default: return $string;
break;
}
}
function StrPrep ($s)
{
$search[0] = '/\>/';
$replace[0] = '> ';
$search[1] = '/\</';
$replace[1] = ' <';
$s = preg_replace($search, $replace, $s);
//$s = str_replace('\*;'*;', ''*;', $s);
//$s = str_replace('&*;quot*;', '"*;', $s);
return $s; // spit out the final webpage for display
}
function StrFix ($s)
{
$search[0] = '/\> /';
$replace[0] = '>';
$search[1] = '/ \</';
$replace[1] = '<';
$s = preg_replace($search, $replace, $s);
//$s = str_replace('\*;'*;', ''*;', $s);
//$s = str_replace('&*;quot*;', '"*;', $s);
return $s; // spit out the final webpage for display
}
?>
"$content["all"]
= (myTagParser ($content["all"]));"
Code: Select all
$content["all"] = (myGlossaryParser ($content["all"]));
Code: Select all
function myGlossaryParser ($string)
{
include_once "glossary.php";
return (glossary($string));
}
useage: just keep adding case lines as in the code
the words with automatically be replaced in the content of your site
BEWARE: ALL instances of the word will be replaced - even in menus etc.