How to NOT display Titles on Static Pages in Drupal
July 06, 2004
Drupal
This is basically a way to style elements according to what kind of node they are in. So a title in a book page will look different than a title in a story.

This is based on some code written by Erik Hopp as shown in This thread
The idea is, we want each element to have a style assigned to it that not only makes a distinction between the ELEMENT type but the NODE type the element is in. So for example, instead of a title being styled only as

   <h1 class="title">This is the Title of a Static Page</h1>

we want the class name to specify that this title is within a "particular" type of node.

        <h1 class="title-page">This is the Title of a Static Page</h1>
or
         <h1 class="title-story">This is the Title of a Story</h1>



Ads by Google

Posted by ellen at July 06, 2004 09:35 AM So if we want to hide the titles on Static Pages, we could set the styles in xtemplate.css like this:
.title-page {
      visibility:hidden;
}

which preserves the space used by the title but hides the title, or like this

.title-page {
      display:none;
}

which does not preserve the space used by the title.

Then we could also create a separate style for .title-story that shows story titles in one color, and another for .title-weblink or whatever other types of nodes are being used.

The steps are

1) in the xtemplate.theme, in the function "xtemplate_node, in the section after

 $xtemplate->template->assign(array(

add the line:

	      "node_type" => $node->type, 

2) in xtemplate.xtmpl, in the node specification, add the node_type variable wherever you need to make the class name more specific. So for instance, instead of

<!-- BEGIN: title -->
    <h2 class="title"><a href="{link}">{title}</a></h2>
    <!-- END: title -->


add the variable node_type after "title":

<!-- BEGIN: title -->
    <h2 class="title-{node_type}"><a href="{link}">{title}</a></h2>
    <!-- END: title -->


The output will be:
<h1 class="title-page"><a href="link to the node">Whatever the title is</a></h1>

Then you can create different styles for each node type if you like.


Ads by Google


Ads by Google

 RSS   |   Contact Me


Ads by Google