本文整理汇总了PHP中unknown::get_template_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown::get_template_vars方法的具体用法?PHP unknown::get_template_vars怎么用?PHP unknown::get_template_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unknown
的用法示例。
在下文中一共展示了unknown::get_template_vars方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_getcontent
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
*/
function smarty_function_getcontent($params, &$bBlog)
{
// Retrieving data
$bBlog->get_sections();
$sections = $bBlog->sections;
foreach ($sections as $object) {
$new[$object->sectionid] = $object;
}
$sections = $new;
$current_section = $bBlog->get_template_vars("sectionid");
// Return
$bBlog->assign("content", $sections[$current_section]->content);
}
示例2: smarty_function_nextprev
/**
*
*
* @param unknown $params
* @param unknown $bBlog (reference)
*/
function smarty_function_nextprev($params, &$bBlog)
{
// Initialize default values...
$skip = 0;
$num = 20;
$max_pages = 0;
$pages_before = 0;
// Set the num parameter
if (is_numeric($params['num'])) {
$num = $params['num'];
}
// Set the max_pages parameter
if (is_numeric($params['max_pages'])) {
$max_pages = $params['max_pages'];
$pages_before = (int) ($max_pages / 2);
}
// Acquire the page skip count; if set, snag it.
$newSkip = $_GET["pageskip"];
if ($newSkip) {
$skip = $newSkip;
}
$sectionid = $_GET["sectionid"];
$QuerySection = '';
$ExtraParams = '';
if ($sectionid) {
$QuerySection .= " AND sections like '%:{$sectionid}:%'";
$ExtraParams .= "§ionid={$sectionid}";
} else {
// This is for the case of Clean URLS
$sectionid = $bBlog->get_template_vars("sectionid");
if ($sectionid) {
$QuerySection .= " AND sections like '%:{$sectionid}:%'";
}
}
$query_params = $params['query'];
if ($query_params) {
$QuerySection .= " AND {$query_params}";
}
$link_params = $params['link'];
if ($link_params) {
$ExtraParams .= $link_params;
}
$posts = $params['posts'];
// Calculate the new offset
$offset = $skip * $num;
$nextoffset = $offset + $num;
$bBlog->assign("current_offset", $offset);
// Get number of entries...
if ($posts) {
$entryCount = count($posts);
if ($params['adjust']) {
$bBlog->assign('posts', array_slice($posts, $offset, $num));
}
} else {
// invariant: Need to query the database and count
$countArray = $bBlog->get_results("select count(*) as nElements from " . T_POSTS . " where status = 'live' {$QuerySection};");
if ($bBlog->num_rows <= 0) {
$entryCount = 0;
} else {
foreach ($countArray as $cnt) {
$entryCount = $cnt->nElements;
}
}
}
// Create the previous pages...
$i = 0;
$current_page = $skip;
if ($max_pages != 0) {
$i = $current_page - $pages_before;
if ($i < 0) {
$i = 0;
}
}
$bBlog->assign("current_page", $current_page + 1);
$bBlog->assign("gofirstpage", $i + 1);
while ($i < $current_page) {
$cp = $i + 1;
$prevpages[] = array('page' => $cp, 'url' => $_SERVER["PHP_SELF"] . "?pageskip={$i}{$ExtraParams}");
++$i;
}
$bBlog->assign("goprevpages", $prevpages);
// Create the next pages
$i = $current_page + 1;
$numberOfPages = (int) ($entryCount / $num);
$pages = $numberOfPages;
if ($pages * $num < $entryCount) {
$pages++;
$numberOfPages++;
}
if ($max_pages != 0) {
$pages = $i + $pages_before;
if ($pages > $numberOfPages) {
$pages = $numberOfPages;
}
//.........这里部分代码省略.........