本文整理匯總了PHP中common_node::getBlogArticleArchive方法的典型用法代碼示例。如果您正苦於以下問題:PHP common_node::getBlogArticleArchive方法的具體用法?PHP common_node::getBlogArticleArchive怎麽用?PHP common_node::getBlogArticleArchive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common_node
的用法示例。
在下文中一共展示了common_node::getBlogArticleArchive方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mainAction
/**
* main action
*/
public function mainAction()
{
/**
* initialise
*/
require_once 'models/common/common_node.php';
$Node = new common_node();
/**
* input data
*/
if (is_numeric($this->GET['blog_node_id'])) {
$blog_node_id = $this->GET['blog_node_id'];
} else {
$blog_node_id = $Node->conf['id_map-blog'];
}
if ($this->GET['date_part'] == 'year-month') {
$date_part = 'year-month';
} else {
$date_part = "year";
}
if (!$this->GET['created']) {
$this->tpl->assign('ACTIVE_CLASS_ALL', 'active');
}
$this->tpl->assign('BLOG_NODE_ID', $blog_node_id);
/**
* process
*/
if ($article_archive = $Node->getBlogArticleArchive($blog_node_id, 1, $date_part)) {
foreach ($article_archive as $item) {
if ($date_part == 'year-month') {
//archive by year-month
$item['created'] = trim($item['date_part'], '()');
$item['created'] = preg_replace('/,/', '-', $item['created']);
//add leading 0 to month 1 to 9 (January to September)
$item['created'] = preg_replace('/^([0-9]{4})-([0-9]{1})$/', '\\1-0\\2', $item['created']);
//formating can be done in template, but in this case formating depends on input
//custom formating can still be done in the template, e.g. {ITEM.created|strtotime|strftime('%B %Y', %s)}
$item['created_formated'] = strftime('%B %Y', strtotime($item['created']));
} else {
//archive by year
$item['created'] = $item['date_part'];
$item['created_formated'] = $item['created'];
}
//active css class
if ($item['created'] == $this->GET['created']) {
$this->tpl->assign('ACTIVE_CLASS', 'active');
} else {
$this->tpl->assign('ACTIVE_CLASS', '');
}
$this->tpl->assign('ITEM', $item);
$this->tpl->parse('content.list.item');
}
$this->tpl->parse('content.list');
}
return true;
}