Adding the Delete op to the vocab Page Title Settings cache flush
[project/page_title.git] / modules / node.page_title.inc
1 <?php
2
3 /**
4 * @file
5 * Node implementations of the page title hooks
6 */
7
8
9 /**
10 * Implementation of hook_page_title_alter().
11 */
12 function node_page_title_alter(&$title) {
13 $menu_item = menu_get_item();
14
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;
24 }
25 }
26
27
28 /**
29 * Implementation of hook_page_title_pattern_alter().
30 */
31 function node_page_title_pattern_alter(&$pattern, &$types) {
32 $menu_item = menu_get_item();
33
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;
38
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);
43 }
44
45 $pattern = variable_get('page_title_type_'. $node->type, '');
46 }
47 }
48
49
50 /**
51 * Implementation of hook_page_title_settings().
52 */
53 function node_page_title_settings() {
54 $settings = array();
55
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'),
62 'show field' => TRUE,
63 'description' => 'This pattern will be used for all %type node-type pages',
64 'description arguments' => array('%type' => $type->name),
65 );
66 }
67
68 return $settings;
69 }