parsing db content
| From: | Martin Kloss | Date: | Wed, 05 Mar 2003 13:45:40 +0000 |
| Subject: | parsing db content | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-8409@lists.php.net to get a copy of this message | ||
Hi there,
I'm having a problem filtering tags in content stored in a db.
Here's what I'm doing:
A db has a table "contents" to store various dynamic contents
of the site.
A PHP script retrieves the content from the db and assigns
it to the array variable $contents. That is because in some cases
there is more than one content on the page.
The template contains the following code to include the contents
in the page:
{foreach from=$contents item="content"}
{foreach from=$content item="c"}
{$c.content}
{/foreach}
{/foreach}
Up to this point everything is fine.
NOW, the designers can enter content into the db through a web interface.
What I want him/her to be able to do is include config settings like {#font#}
in the content text, so that the content text is formatted according to the
settings in the config files. BUT of course the content is displayed as:
{#font#}This is the content
on the page, since the {} are not parsed.
How can I achieve that the contents are parsed without manually replacing
the {#font#} tag with a regex function in the PHP script after pulling it from
the database?
I thought of adding a pre-filter function, but then I would also have to write a
function to replace {#font#} with <FONT FACE....> and all the other tags,
which would not make any sense, since smarty is supposed to do work like
that. Any ideas?
Martin.
Martin Kloss
Need music? http://www.selling-sound.com
Like the author? Buy the book at:
http://www.amazon.de/exec/obidos/ASIN/3898422194/lingmmugd
Get your daily dose of Lingo at the LingoPark:
http://www.lingopark.com