我真的很聪明.我想知道如何在smarty中使用一组
PHP函数.我知道有些功能可以直接使用.
例如:{$my_string | strip_tags}
我正在使用PDO和smarty.请在下面的代码中查看我的帖子
$stmnt = $conn->prepare("SELECT post_id, post_title FROM posts ORDER BY post_id DESC");
$stmnt ->execute();
$row = $stmnt ->fetchAll();
$my_template = new Smarty;
$my_template->debugging = false;
$my_template->caching = true;
$my_template->cache_lifetime = 120;
$my_template->setTemplateDir('./templates/’');
$my_template->assign("row", $row);
$my_template->display('posts.tpl');
//in my smartyposts.tpl
{foreach $row as $r}
//display posts here
{/foreach}
我想使用一些php函数从post_title创建url.通常我在php中做什么
foreach($row as $r){
$post_title = $r[‘post_title’];
$create_link = preg_replace("![^a-z0-9]+!i", "-", $post_title);
$create_link = urlencode($create_link);
$create_link = strtolower($create_link);
?>