5 * Node implementations of the page title hooks
10 * Implementation of hook_page_title_alter().
12 function node_page_title_alter(&$title) {
13 $menu_item = menu_get_item();
15 // Test if this is a node page.
16 if ( !strncmp($menu_item['path'], 'node/%', 6) &&
17 ($node = menu_get_object()) &&
18 !empty($node->page_title
) &&
19 variable_get('page_title_type_'.
$node->type .
'_showfield', 0)) {
20 // If the node has a custom page title and the node type is configured
21 // to have a custom page title (ie, it's not a leftover from a previous
22 // setting), then use it.
23 $title = $node->page_title
;
29 * Implementation of hook_page_title_pattern_alter().
31 function node_page_title_pattern_alter(&$pattern, &$types) {
32 $menu_item = menu_get_item();
34 // Test if this is a node page.
35 if ( !strncmp($menu_item['path'], 'node/%', 6) &&
36 $node = menu_get_object() ) {
37 $types['node'] = $node;
39 // If the node has any taxonomy, grab the first term for user in tokens.
40 // TODO: Handle multiple terms? Only pass specific terms per content type?
41 if (!empty($types['node']->taxonomy
)) {
42 $types['taxonomy'] = current($types['node']->taxonomy
);
45 $pattern = variable_get('page_title_type_'.
$node->type
, '');
51 * Implementation of hook_page_title_settings().
53 function node_page_title_settings() {
56 $types = node_get_types();
57 foreach ($types as
$type) {
58 $settings['page_title_type_'.
$type->type
] = array(
59 'label' => 'Content Type - %type',
60 'label arguments' => array('%type' => $type->name
),
61 'scopes' => array('global', 'node', 'taxonomy'),
63 'description' => 'This pattern will be used for all %type node-type pages',
64 'description arguments' => array('%type' => $type->name
),