function wp_blog_node_view in WP Blog - a WordPress-style blogging module. 7
Implements hook_node_view().
File
- ./
wp_blog.module, line 114 - WP Blog provides a content-type, taxonomy vocabulary, views and various features to mimic a WordPress-style blog.
Code
function wp_blog_node_view($node, $view_mode, $langcode) {
// Only act on full page views for WP blog nodes.
if (!($view_mode == 'full' && $node->type == WP_BLOG_DEFAULT_CTYPE)) {
return;
}
// Set an appropriate menu-trail based on the path alias (which should be
// blog/yyyy/mm/dd/title).
$date = (object) getdate($node->created);
$trail = array(
array(
'title' => t('Home'),
'href' => '<front>',
'localized_options' => array(),
'type' => MENU_NORMAL_ITEM,
),
array(
'title' => t('Blog'),
'href' => 'blog',
'localized_options' => array(),
'type' => MENU_NORMAL_ITEM,
),
array(
'title' => $date->year,
'href' => "blog/{$date->year}",
'localized_options' => array(),
'type' => MENU_NORMAL_ITEM,
),
array(
'title' => t($date->month, array(), array(
'context' => 'Long month name',
)),
'href' => "blog/{$date->year}/" . str_pad($date->mon, 2, '0', STR_PAD_LEFT),
'localized_options' => array(),
'type' => MENU_NORMAL_ITEM,
),
array(
'title' => t('@day<sup>@ordinal</sup>', array(
'@day' => $date->mday,
'@ordinal' => t(date('S', $node->created), array(), array(
'context' => 'Date ordinal suffix',
)),
)),
'href' => "blog/{$date->year}/" . str_pad($date->mon, 2, '0', STR_PAD_LEFT) . "/" . str_pad($date->mday, 2, '0', STR_PAD_LEFT),
'localized_options' => array(
'html' => TRUE,
),
'type' => MENU_NORMAL_ITEM,
),
array(
'title' => $node->title,
'href' => "node/{$node->nid}",
'localized_options' => array(),
'type' => MENU_NORMAL_ITEM,
),
);
menu_set_active_trail($trail);
}