1

In display modes I set to hidden all Title fields, but Views still gives h2 title. enter image description here

  • Also looking for an answer to it, tried title module but didn't help. subscribing – user17594 Mar 31 '14 at 17:48
  • I was told it's rendering entire node content, so you should get some custom content type display mode.tpl.php file with some custom scripts in your theme template.php file, but I failed, because this is way out of my league. – Optimus Prime Mar 31 '14 at 17:51
  • i use css to accomplish this – frazras Mar 5 '15 at 13:06
0

Every page should contain a heading.

You should always maintain a structured hierarchy of headings within any web page. You should never have a blank heading or even hide it with display:none;. Hiding any content which isn’t viewable by your visitors but is by search engines is against Google’s guidelines as your intention is to only manipulate search engine results by including it. Restyle a heading tag so it fits into your design is the best option.

If you still have to hide it then a better option would be to either create a template for that node, content type or page and simply not print the heading.

Or if you want to use CSS then use position:absolute so the heading doesn’t use any space where it is located in the page and text-indent:-9999px; so the text is moved off the screen and no longer visible but at least can be read by screen readers and search engines.

  • 1
    OP is looking for a way to hide the title of a node that is embedded in a view. The view provides the page title (what you refer to as "heading"). So your concern is not valid here. – batigolix Aug 12 '15 at 16:07
  • heading refers to title. – WaQaR Ali Aug 12 '15 at 16:11
  • yes, you call it "heading". in drupal that is referred to as "title" – batigolix Aug 12 '15 at 16:12
1

Views renders the node entity using the default view mode (machine name 'full'). Drupal uses the node.tpl.php template to output the node. That template contains a condition to check for the $page variable. If that is false than it prints the title of the node as a link.

The are various solutions (such as using a different view mode or tinkering with node.tpl.php) but you can also clear the title using hook_node_view.

You can check if the node is the same as the one returned by menu_get_object. If that is not the case than the node is somehow embedded in another node or in a view (as is your case).

function MYMODULE_node_view($node, $view_mode, $langcode) {
  $page_node = menu_get_object();
  if ($node->nid != $page_node->nid) {
    $node->title = NULL;
  }
}

I havent experienced any bad side effects, yet.

See drupal.org for more info.

1

Providing a specific display without a title using the Display Suite module may be a quick way to address this. Not does it only allow you to hide the title, if you do want to display a title, you can change the heading from the default <h2> to <h3> for instance…

I've done this before with success.

0

You can copy node.tpl.php to your local theme and check based on whether there is a view name or based on a particular view name. The following example removes the link from a specific view.

<?php
$view = views_get_page_view();
$view_name = '';
if (!empty($view)) {
  $view_name = $view->name;
}
?>
<article id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
 <?php if ((!$page && !empty($title)) || !empty($title_prefix) || !empty($title_suffix) || $display_submitted): ?>
<header>
  <?php print render($title_prefix); ?>
  <?php if (!$page && !empty($title) && $view_name == 'photographer_of_the_year'): ?>
    <h2<?php print $title_attributes; ?>><?php print $title; ?></h2>
  <?php elseif (!$page && !empty($title)): ?>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
...
0

If you have the entity-module installed, you can do the following: Copy the file

sites/all/modules/entity/entity.tpl.php

into your theme-folder.

Duplicate the file and rename it to the machine-name of your entity, for example

"commerce-product.tpl.php"

or, to be more specific just for the teaser:

"commerce-product--product--node-teaser.tpl.php"

In the file you can delete (or just change) the following part:

<?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>>
      <?php if ($url): ?>
        <a href="<?php print $url; ?>"><?php print $title; ?></a>
      <?php else: ?>
        <?php print $title; ?>
      <?php endif; ?>
    </h2>
  <?php endif; ?></code>

To find the correct template-name use the submodule "theme developer" of the "devel"-module.

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.