页面标题没有更新? Drupal / PHP钩子标题

时间:2014-11-12 09:56:43

标签: html css drupal drupal-7

我正在尝试更改我的页面标题。要访问该页面 - click here

这是作为Drupal 7中的自定义模块编写的。该文件在JSFiddle中被称为wb_spc.module,用于此模块代码,请click here

我尝试过更改第51行和第59行,但这不会改变h1页面标题吗?

请参阅下面的代码段:

/**
 * Implements hook_menu().
 */
function wb_spc_menu() {
  $items = array();

  // Admin configuration group.
  $items['admin/config/wb_spc'] = array(
    'title' => 'Workbooks Self-Assessment CRM ROI Calculator',
    'description' => 'Administer WB CRM Requirements',
    'access arguments' => array('administer wb crm requirements'),
  );

  // Admin configuration - Settings.
  $items['admin/config/wb_spc/manage'] = array(
    'title' => 'Workbooks Self-Assessment CRM ROI Calculator Settings',
    'description' => 'Manage WB CRM Requirements settings and configurations.',
    'access arguments' => array('administer wb spc requirements'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('wb_spc_admin_settings_form'),
  );

  $items[variable_get('wb_spc_path')] = array(
    'title' => 'Workbooks Self-Assessment CRM ROI Calculator', 
    'page callback' => 'drupal_get_form', 
    'page arguments' => array('wb_spc_form'),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  $items['wb_spc/test'] = array(
    'title' => 'TESTING - Workbooks Self-Assessment CRM ROI Calculator', 
    'page callback' => 'wb_spc_test', 
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  $items['wb_spc/results/%'] = array(
    'title' => 'WB Show PDF', 
    'page callback' => 'wb_spc_show_pdf', 
    'page arguments' => array(2),
    'access arguments' => array('access content'),
  );
  return $items;
}

1 个答案:

答案 0 :(得分:3)

在页面(您作为用户看到的页面)中,添加以下内容:

drupal_set_title('Page title goes here');

更改<h1>,我相信如果您这样做,页面标题也会更改。如果您希望页面标题不是<h1>,请使用方法drupal_set_title('Page title goes here');

要仅从某个页面更改它,请使用:

if($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] == 'www.yourdomain.com/rest/of/url'){
    drupal_set_title('Page title goes here');
}