1

I am trying to alter the page title of history content type using this function

function mytheme_preprocess_page(&$variables) {
   if(isset($variables['node']) && $variables['node']->type == "your_content_type") {
   drupal_set_title("my_title");    
 }
}

But you know what, I dont get anything in node array.

enter image description here

2

You could use hook_node_view, which also gives you more flexibility, (e.g. control what view mode / language you affect):

function MY_MODULE_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'your-node-type' && $view_mode == 'full') {
    drupal_set_title('your-title');
}

Instead of using a preprocess function, which is better for template changes, (for example, adding variables to it):

The main role of the preprocessors is to set up variables to be placed within the template (.tpl.php) files.

Preprocess and process functions

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.