本文整理匯總了PHP中view::parse方法的典型用法代碼示例。如果您正苦於以下問題:PHP view::parse方法的具體用法?PHP view::parse怎麽用?PHP view::parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類view
的用法示例。
在下文中一共展示了view::parse方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: article
/**
* 生成文章頁麵
*/
function article()
{
//讀取總數
if (!$_SESSION['article']['total']) {
$_SESSION['article']['total'] = (int) sf::getModel("articles")->getTotal("`is_html` = 0");
$_SESSION['article']['num'] = 0;
}
//生成靜態頁麵
if ($_SESSION['article']['total'] == 0 || $_SESSION['article']['num'] >= $_SESSION['article']['total']) {
$_SESSION['article']['num'] = 0;
$_SESSION['article']['total'] = 0;
exit('{total:1,num:1}');
}
$result = sf::getModel("articles")->selectAll("is_html = 0", '', 1);
while ($article = $result->getObject()) {
view::set("article", $article);
view::apply("inc_body", "template/article_show");
$htmlStr = view::parse("template/page");
$path = WEBROOT . "/html/" . $article->getTypeStr();
if (!is_dir($path)) {
sf::getLib("Files")->mDir($path);
exit('{total:' . $_SESSION['article']['total'] . ',num:0}');
}
sf::getLib("Files")->write($path . "/article-show-" . $article->getId() . ".html", $htmlStr);
$article->setIsHtml(1);
$article->save();
$_SESSION['article']['num']++;
}
exit('{total:' . $_SESSION['article']['total'] . ',num:' . $_SESSION['article']['num'] . '}');
}
示例2: display_template
function display_template($name, $params)
{
$content = new view($name);
$content->parse($params);
}