Hi,
I'm working on a new site that will use a lot of specialized terms that should always be styled (i.e.italics). I suppose I could do this in php but I thought I'd try to see if the function already exists as a module and am not finding anything.

I'm thinking that in the admin area I would be able to add in a list of terms and on page load a defined style would always get applied to a matched term.

If anyone knows of a module that already does this or something like it please tell me.

If this is best done as straight php, is adding it to my template file the right way to go?

thanks,
david

Comments

biscuit.tech’s picture

I've decided to start trying to get this to work by adding a function to my template.php file, for right now I'm just using the standard Garland theme.

I've created a table called sanskrit_words with a field called word and made a couple of entries, and I've added a style to style.css but when I view a node that has matching words I am not seeing them styled.

This is the first time I've tried something like this so I would appreciate any help.

Here's the code I've got:

function phptemplate_italicize_sanskrit_words($content)
{
   $r=mysql_query('SELECT word FROM sanskrit_words');
   while($a=mysql_fetch_assoc($r))
   {
       $pattern=sprintf('/\b(%s)\b/i',preg_quote($a['word']));
       $content=preg_replace($pattern,'<span
class="sanskrit">$1</span>',$content);
   }
   return $content;
}
biscuit.tech’s picture

I've moved this from Post-Install to Module Development hoping that someone can give me some help or suggest an existing module that already does this - I haven't been able to find anything like it.

thanks.