本文整理汇总了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;
}