当前位置: 首页>>代码示例>>PHP>>正文


PHP api::set_new_tpl方法代码示例

本文整理汇总了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;
}
开发者ID:Kylaksizov,项目名称:apps-system,代码行数:37,代码来源:news_min.php

示例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);
开发者ID:Kylaksizov,项目名称:apps-system,代码行数:30,代码来源:page.php


注:本文中的api::set_new_tpl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。