page_title.page_title.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @file
  4. * Page Title implementations of the page title hooks
  5. */
  6. /**
  7. * Implements hook_page_title_alter().
  8. */
  9. function page_title_page_title_alter(&$title) {
  10. // If nothing above set a title, give the legacy function a chance to act
  11. if (empty($title)) {
  12. $title = page_title_set_title();
  13. }
  14. // If we still have no title, fall back to the title provided by Drupal Core
  15. if (empty($title)) {
  16. $title = strip_tags(drupal_get_title());
  17. }
  18. }
  19. /**
  20. * Implements hook_page_title_pattern_alter().
  21. */
  22. function page_title_page_title_pattern_alter(&$pattern, &$types) {
  23. // If frontpage, then use the frontpage pattern and set the title.
  24. if (drupal_is_front_page()) {
  25. // Get the frontpage pattern
  26. $settings = page_title_get_settings();
  27. $pattern = variable_get('page_title_front', $settings['page_title_front']['default']);
  28. }
  29. }
  30. /**
  31. * Implements hook_page_title_settings().
  32. */
  33. function page_title_page_title_settings() {
  34. return array(
  35. 'page_title_default' => array(
  36. 'label' => 'Default',
  37. 'scopes' => array('global'),
  38. 'required' => TRUE,
  39. 'show field' => FALSE,
  40. 'description' => 'This pattern will be used as a <em>fallback</em> (ie, when no other pattern is defined)',
  41. 'weight' => -50,
  42. 'default' => '[current-page:page-title] | [site:name]',
  43. ),
  44. 'page_title_front' => array(
  45. 'label' => 'Frontpage',
  46. 'scopes' => array('global'),
  47. 'show field' => FALSE,
  48. 'description' => 'This pattern will be used for the site frontpage',
  49. 'weight' => -49,
  50. 'default' => '[site:name] | [site:slogan]',
  51. ),
  52. 'page_title_pager_pattern' => array(
  53. 'label' => 'Pager Suffix',
  54. 'scopes' => array('global'),
  55. 'show field' => FALSE,
  56. 'description' => 'This pattern will be appended to a page title for any given page with a pager on it',
  57. 'weight' => -48,
  58. ),
  59. );
  60. }