我为我的公司创建了一个新网站,我想使用smarty(v3.1.29)。 现在问题是我们存储 b> 代码 b>所有页面在我们的数据库 b>(家庭,产品,下载,...)。 有些页面包含PHP内联函数,如: p>
在我的模板(.tpl)文件中,我有一个div部分来加载我们数据库中的内容: p>
<前> 所以我的代码后来看起来像这样: p>
有没有办法聪明地处理 解析之前的PHP代码? p>
提示:我不想编辑我的模板文件。 我只是想将数据库内容解析到我网站的内容部分。 b>
&lt;?php include(“functions.php”); ?&GT;
&LT; p为H. 你好&lt;?php echo printWorldInColor(); ?&GT; &lt; / p&gt;
code> pre>
&lt; html&gt;
&lt; body&gt;
&lt; div id =“content”&gt;
{$ content}
&lt; / div&gt;
&lt; / body&gt;
&lt; / html&gt;
code> pre>
&lt; html&gt; \ n&lt; body&gt;
&lt; div id =“content”&gt;
&lt;?php include(“functions.php”); ?&GT;
&lt; p&gt; 你好&lt;?php echo printWorldInColor(); ?&GT; &lt; / p&gt;
&lt; / div&gt;
&lt; / body&gt;
&lt; / html&gt;
code> pre>
我尝试过: p>
I make a new website for my company and i want to use smarty (v3.1.29) for it. Now the problem is that we store the code for all pages in our database (home, products, downloads, ...). Some pages contains PHP inline functions like:
<?php include("functions.php"); ?>
<p> Hello <?php echo printWorldInColor(); ?> </p>
In my template (.tpl) file I have a div-section to load the content from our database:
<html>
<body>
<div id="content">
{$content}
</div>
</body>
</html>
So my code looks like this afterwards:
<html>
<body>
<div id="content">
<?php include("functions.php"); ?>
<p> Hello <?php echo printWorldInColor(); ?> </p>
</div>
</body>
</html>
Is there a way that smarty processes the PHP-code before parsing it?
Hint: I dont want to edit my template file. I just want to parse the database content to my content-section of the website.
What i tried:
- saved database-content into a string and replaced PHP-tags with smarty-PHP-tags, then assign it to the template
- SmartyBC-Class