本文整理汇总了PHP中api::set_new_tpl方法的典型用法代码示例。如果您正苦于以下问题:PHP api::set_new_tpl方法的具体用法?PHP api::set_new_tpl怎么用?PHP api::set_new_tpl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::set_new_tpl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowNews
function ShowNews($template_news = NULL, $params = NULL, $args)
{
$api_news = new api(APPLICATION_NAME);
# подключаем шаблон кратких новостей -> news_min.tpl
if ($template_news == NULL) {
$news_min_template = $api_news->get_file("news_min.tpl");
} else {
$news_min_template = $api_news->get_file($template_news);
}
# поиск тегов {date...}
//preg_match_all('#{date\s*(=\s*\"(s||m||h||d||w||auto)\")?}#is', $news_min_template, $arr_date);
//FunctionPublic::Pre($arr_date);
# Достаём из таблицы новости
//$news = DB::select(PREFIX_."news", $params);
$news = DB::run("SELECT * FROM " . PREFIX_ . "news " . $params, $args)->fetchAll(PDO::FETCH_ASSOC);
//FunctionPublic::Pre($params);
$news_min_all = "";
$result = "";
if ($news) {
// если есть хоть одна новость
# перебираем все новости и заносим в переменную
foreach ($news as $value) {
$date = unserialize($value["time"]);
//$time_news = FunctionPublic::getTime($date["time"], "s");
$result = $api_news->set_new_tpl("{title}", $value["title"], $news_min_template);
$result = $api_news->set_new_tpl("{news_link}", $value["url"] . ".html", $result);
$result = $api_news->set_new_tpl("{news_min}", $value["news_min"], $result);
$result = $api_news->set_new_tpl("{category_link}", "{HOME}" . $value["cat_url"], $result);
$result = $api_news->set_new_tpl("{category_name}", $value["cat_name"], $result);
$result = $api_news->set_new_tpl("{date}", $date["date"], $result);
$news_min_all .= $result;
}
unset($news);
unset($value);
}
return $news_min_all;
}
示例2: api
$news_max = new api(APPLICATION_NAME);
$news_max_template = $news_max -> get_file("news_max.tpl");
$news = DB::run("SELECT * FROM " . PREFIX_ . "news WHERE status = ? and url = ? LIMIT 1", array("1", $url["result"])) -> fetchAll(PDO::FETCH_ASSOC);
if($news){ // если есть хоть одна новость
# перебираем все новости и заносим в переменную
foreach ($news as $value) {
$date = unserialize($value["time"]);
//$time_news = FunctionPublic::getTime($date["time"], "s");
$result = $news_max -> set_new_tpl("{title}", $value["title"], $news_max_template);
$result = $news_max -> set_new_tpl("{news_max}", $value["news_max"], $result);
$result = $news_max -> set_new_tpl("{date}", $date["date"], $result);
$result = $news_max -> set_new_tpl("{category_link}", "{HOME}" . $value["cat_url"], $result);
$result = $news_max -> set_new_tpl("{category_name}", $value["cat_name"], $result);
}
$api -> set("{header_title}", $value["title"]);
$api -> set("{header_description}", $value["description"]);
$api -> set("{header_keywords}", $value["keywords"]);
$api -> set("{content}", '<div class="content_blog">'.$result.'</div>');
unset($news);
unset($value);