Displaying Node Title instead of Content Type as H1

+1
+8
-1

Hello everyone,

i'd like to know if someone could please explain how i can change this to show only the node title instead of the content type as the page title.

I've read on drupal.org that this is a feature of Nucleus, and i noticed that on the "Basic Page" content type it doesn't happen, only on the other content types, but i couldn't find out how to change it.

If someone could help with this, i would appreciate it very much.

Best Regards,

Bruno

+1
-16
-1

I'm not sure which theme you are using. But please look these points to know how it work:

in preprocess_functions.inc

function tb_sirate_preprocess_page(&$vars) {
if (isset($vars['node'])) {
if ($vars['node']->type != 'page') {
$result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
->fields('node_type', array('name'))
->condition('type', $vars['node']->type)
->execute();
foreach ($result as $item) {
$vars['title'] = $item['name'];
}
}
}
}
function tb_sirate_preprocess_node(&$vars) {
$vars['page'] = ($vars['type'] == 'page') ? TRUE : FALSE;
}

in page.tpl.php

<?php if ($title): ?>
<h1 id="page-title"><span><?php print $title; ?></span></h1>
<?php endif; ?>

and in node.tpl.php

<?php if ($title && !$page): ?>
<div class="header article-header">
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<h2<?php print $title_attributes; ?>>
<a href="<?php print $node_url; ?>"><?php print $title; ?></a>
</h2>
<?php endif; ?>
<?php print render($title_suffix); ?>
</div>
<?php endif; ?>

HaiNN

+1
-22
-1

Thanks.

I'm using Sirate, but i also noticed it happens on Methys too, wich i'm planning to use on another project.

Thanks to your post, i now know where to look for the functions, but i'm still a little puzzled, as i'm relatively new to coding anything outside of css :(

+1
-5
-1

Solution for the Metroz theme:

  1. Fetch the file template.php
  2. In its code, find the function tb_metroz_preprocess_page(&$vars) (currently this is somewhere around line 53)
  3. Comment out the first block of code in that function as follows:
    function tb_metroz_preprocess_page(&$vars) {
    /*
    if (isset($vars['node']) && $vars['node']->type != 'page' && !in_array('page__node__delete', $vars['theme_hook_suggestions'])) {
    $result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
    ->fields('node_type', array('name'))
    ->condition('type', $vars['node']->type)
    ->execute()->fetchField();
    $vars['title'] = $result;
    }
    */

Once this is done, refresh a page of a content type other than Basic page. It should work fine for other content types now, as well as for the basic pages (and Views).

(I have no idea why that code is in there in the first place?)

+1
-5
-1

Solution for the Metroz theme (part 2):

"Now I have two titles displayed: the bar above and in the node."

To remove the title in the node itself:

  1. Fetch the file node.tpl.php (in the "tpl"-folder)
  2. In its code, remove (our comment out) the following piece of code (currently around line 84):
    <?php if ($title && !$page): ?>

    <?php print render($title_prefix); ?>
    <?php if ($title): ?>
    < h2<?php print $title_attributes; ?>>
    < a href=<?php print $node_url; ?>><?php print $title; ?>
    < /h2>
    <?php endif; ?>
    <?php print render($title_suffix); ?>

    <?php endif; ?>

Done.

+1
+1
-1

Hey,
I have also faced this problem, but was able to come over it.
So here is the solution for anyone, who may find this thread and wants a solution.

in the sites/all/themes/tb_sirate/inc/preprocess_functions.inc file, search for this piece of code:

function tb_sirate_preprocess_page(&$vars) {
  if (isset($vars['node'])) {
    if ($vars['node']->type != 'page' && false) {
      $result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
        ->fields('node_type', array('name'))
        ->condition('type', $vars['node']->type)
        ->execute();
      foreach ($result as $item) {
        $vars['title'] = $item['name'];
      }
    }
  }
}

This actually check if the current node's type is 'page' then the page title is the node title, but in every other case it sets the page title as the node type. It seems like this is not a bug, this was intended to be a "feature".

Anyway, you can disable this by swapping the code above to this:

function tb_sirate_preprocess_page(&$vars) {
  // yes, this whole function was written only for this "feature"
}

Cheers!

Comments

What would be the change in

What would be the change in preprocess_functions.inc for a TB Methys II site if instead of showing the content type, it could show the current selected term of a vocabulary? Say, your URL path is /rock/name-of-article-goes-here and you want that instead of "ARTICLE", "ROCK" shows up? Better yet if that term can be made into a clicklable link. Thanks,

I'm struggling with the same

I'm struggling with the same behaviour in the TB_Metroz theme.

The Basic Page content type displays the title correctly, but any other content doesn't. It displays the name of the content type (e.g. "Article", "Webform") instead of the page title.

I don't think the code provided above is working for this theme, I couldn't find a solution in the configuration pages either. Please help.