Skip to main content
added 22 characters in body; edited tags; edited title
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How todo I overwrite node title for specific content type?

I'm trying to add a chapter tag (§) in front of a title for content type 'ABC' in a Drupal 7 site. I

I tried the following:

function mytheme_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';
  }
  //watchdog("mytheme_preprocess_node", 'items %items', array('%items' => print_r($variables['node'], true)));
  $node = $variables['node'];
  if ($node->type=='abc') {
    $node->title = 'this is a test' . $node->title; 
    $variables['node'] = $node;
    watchdog("mytheme", 'items %items', array('%items' => print_r($variables['node'], true)));
  }
}

I did see the message output in the log, however updated title is not showing up on the site.

How to overwrite node title for specific content type?

I'm trying to add a chapter tag (§) in front of a title for content type 'ABC'. I tried the following:

function mytheme_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';
  }
  //watchdog("mytheme_preprocess_node", 'items %items', array('%items' => print_r($variables['node'], true)));
  $node = $variables['node'];
  if ($node->type=='abc') {
    $node->title = 'this is a test' . $node->title; 
    $variables['node'] = $node;
    watchdog("mytheme", 'items %items', array('%items' => print_r($variables['node'], true)));
  }
}

I did see the message output in the log, however updated title is not showing up on the site

How do I overwrite node title for specific content type?

I'm trying to add a chapter tag (§) in front of a title for content type 'ABC' in a Drupal 7 site.

I tried the following:

function mytheme_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';
  }
  //watchdog("mytheme_preprocess_node", 'items %items', array('%items' => print_r($variables['node'], true)));
  $node = $variables['node'];
  if ($node->type=='abc') {
    $node->title = 'this is a test' . $node->title; 
    $variables['node'] = $node;
    watchdog("mytheme", 'items %items', array('%items' => print_r($variables['node'], true)));
  }
}

I did see the message output in the log, however updated title is not showing up on the site.

Source Link
Vlad Vinnikov
  • 195
  • 1
  • 2
  • 9

How to overwrite node title for specific content type?

I'm trying to add a chapter tag (§) in front of a title for content type 'ABC'. I tried the following:

function mytheme_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';
  }
  //watchdog("mytheme_preprocess_node", 'items %items', array('%items' => print_r($variables['node'], true)));
  $node = $variables['node'];
  if ($node->type=='abc') {
    $node->title = 'this is a test' . $node->title; 
    $variables['node'] = $node;
    watchdog("mytheme", 'items %items', array('%items' => print_r($variables['node'], true)));
  }
}

I did see the message output in the log, however updated title is not showing up on the site