本文整理汇总了PHP中SmartyPaginate::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP SmartyPaginate::assign方法的具体用法?PHP SmartyPaginate::assign怎么用?PHP SmartyPaginate::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartyPaginate
的用法示例。
在下文中一共展示了SmartyPaginate::assign方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: roles
$rolesobj = new roles();
//get folders
$folders = $myfile->getProjectFolders($id);
//get all folders
$allfolders = $myfile->getAllProjectFolders($id);
//get the project
$pro = $myproject->getProject($id);
//get the project members
$members = $myproject->getProjectMembers($id, 10000);
//get all roles
$allroles = $rolesobj->getAllRoles();
$projectname = $pro["name"];
$title = $langfile['files'];
$template->assign("title", $title);
$template->assign("projectname", $projectname);
SmartyPaginate::assign($template);
$template->assign("files", $files);
$template->assign("filenum", $filenum);
$template->assign("folders", $folders);
$template->assign("members", $members);
$template->assign("roles", $allroles);
$template->assign("allfolders", $allfolders);
$template->assign("postmax", $POST_MAX_SIZE);
$template->display("projectfiles.tpl");
} elseif ($action == "addfolder") {
if (!$userpermissions["files"]["add"]) {
$errtxt = $langfile["nopermission"];
$noperm = $langfile["accessdenied"];
$template->assign("errortext", "<h2>{$errtxt}</h2><br>{$noperm}");
$template->display("error.tpl");
die;
示例2: foreach
$X = SmartyPaginate::getCurrentIndex();
$Y = SmartyPaginate::getLimit();
$searchSQL = "SELECT * FROM sionapros_news WHERE 1 ORDER BY news_no DESC LIMIT {$X},{$Y}";
$result = $dbcon->execute($searchSQL);
foreach ($result as $row) {
// collect each record into $_data
$data[] = $row;
}
// now we get the total number of records from the table
$rowsSQL = "SELECT COUNT(*) FROM sionapros_news WHERE 1";
$dbcon->query($rowsSQL);
#$rowNo = $rows[0];
SmartyPaginate::setTotal($dbcon->getValue());
$dbcon->free();
return $data;
}
$results = getSearchResults($db);
if (sizeof($results) == 0) {
$searchMsg = 'NO ARTICLES WERE FOUND';
$smarty->assign('searchMsg', $searchMsg);
} else {
// assign your db results to the template
$smarty->assign('news', $results);
// assign {$paginate} var
SmartyPaginate::assign($smarty);
}
$content = $smarty->fetch('./news/tm0.news.display_news.tpl.html');
SmartyPaginate::disconnect();
?>
示例3: viewlist
function viewlist($parameter = null, $layout = true, $model = false)
{
$options = array();
$assigns = array();
$model = $model ? $model : $this->getDefaultModel();
$this->page_title = Inflector::humanize($this->name);
$this->auto_render = false;
$this->base_dir = APP_DIR;
$assigns['TITLE'] = Inflector::humanize($this->name);
if ($model) {
$this->get_search_field($model, $options);
$this->get_viewlist_options($model, $options);
$this->get_sort_options($model, $options);
$this->set_pagination($model);
$model->find($options);
$page_content =& NController::singleton('page_content');
$page_content_model =& $page_content->getDefaultModel();
$pk = $model->primaryKey();
$models = array();
$headline = $model->getHeadline() ? $model->getHeadline() : 'cms_headline';
$i = 0;
while ($model->fetch()) {
$arr = $model->toArray();
$arr['_headline'] = isset($arr['cms_headline']) && $arr['cms_headline'] ? $arr['cms_headline'] : $model->makeHeadline();
$arr['_remove_delete'] = $page_content_model->isWorkflowContent($this->name, $arr[$pk]) ? 1 : 0;
// Remove delete for models that have specified this.
$arr['_remove_delete'] = isset($model->remove_delete) && $model->remove_delete == true ? 1 : 0;
$models[] = $arr;
unset($arr);
}
// Override standard paging limit if chosen in the model file.
$paging = isset($model->paging) ? $model->paging : $this->paging;
// If paging is not disabled in the model AND the records are > than the paging size AND not searching.
if ($paging > 0 && count($models) > $paging && !$options['is_search']) {
SmartyPaginate::connect($this->name);
SmartyPaginate::setLimit($paging, $this->name);
SmartyPaginate::setTotal(count($models), $this->name);
$view =& NView::singleton($this);
SmartyPaginate::assign($view, 'paginate', $this->name);
// TODO: Could be more efficient and only get records it needs to.
$models = array_slice($models, SmartyPaginate::getCurrentIndex($this->name), SmartyPaginate::getLimit($this->name));
$this->set('paging', true);
}
$this->set(array('rows' => $models, 'asset' => $this->name, 'asset_name' => $this->page_title));
unset($models);
}
$this->render(array('layout' => 'default'));
}