I want to remove the H1 title of pages that's in the div content-header. However I only want to do this for content ive created. I want logged in users to still see the title of pages in the admin menu.

By removing some php from page.tpl.php I can hide the title, but the title of pages from the admin menu disappear aswell.

Thanks

Comments

WorldFallz’s picture

Did you try simply removing <?php print $title ?> (or something like that depending upon your theme) from node.tpl.php?

jdln’s picture

I tried removing that code from node.tpl.php on my override template but nothing happened.

I then removed all the content from that page as a test and again nothing happened.

I thought this was an override issue and to check i removed all the content from node.tpl.php in the zen folder (the template im using) and nothing happens when i cleat the cache and refresh the page. This seems strange as if i remove the content from template.php in the same zen folder, this does have an effect on the page.

Id really appreciate any feedback on this but should i be posting in the zen template forum?

Thanks

WorldFallz’s picture

hmmm... are you using your own subtheme of zen? If so, you'll need to copy the base node.tpl.php file to the directory of your subtheme, then any additional node-*.tpl.php files should be detected properly. Then, if you remove all the content from node-type.tpl.php you should get a completely blank content area for nodes of that content type.

jdln’s picture

Ive just realized something. The code you suggested commenting out is in h2 tags;

  <?php if (!$page): ?>
    <h2 class="title">
      <a href="<?php print $node_url; ?>" title=""><?php print $title; ?></a>
    </h2>
  <?php endif; ?>

But the title im trying to remove is in h1 tags. Presumably that means node.tpl.php is the wrong file and this isnt a zen template issue.

The h1 tag im trying to remove is in this code on the page;

<div id="content-header">
  <h1 class="title">About Us</h1>
    <div class="tabs">
        <ul class="tabs primary clear-block">
                (there is some more content in here)
        </ul>
    </div>
</div>
WorldFallz’s picture

If it's in h1 tags, then you probably need to edit the page-tpl.php file instead. And again, you'll need to copy the base page.tpl.php file to your subtheme directory before any derivative suggestions are detected.

jdln’s picture

Ive set up the override for my page.tpl.php. The problem is that if i remove this;

<?php print $title; ?>

From here;

<?php if ($title): ?>
              <h1 class="title"><?php print $title; ?></h1>
            <?php endif; ?>

Then the content-header title is removed from my Admin pages aswell as my content pages. What I need is for it to be removed from my content page only.

Sorry if i sent you on the wrong course their by talking about my template.

Thanks

WorldFallz’s picture

Try changing <?php if ($title): ?> to <?php if ($title && arg(0) != 'node'): ?> -- let me know if that works.

jdln’s picture

Its worked for pages ive created by not for the blog and contact page.

Its removed the title of Create Content links but not of My Account or Administer.

WorldFallz’s picture

You'll have to play around with the condition to get exactly what you want. For example, to add blogs, try:

<?php if ($title && arg(0) != 'node' && arg(0) != 'blog'): ?>

The http://api.drupal.org/api/function/arg function merely grabs the various pieces of the URL so you should be able to get at most of what you need with it.

jdln’s picture

OK. This is beyond me at the moment, im new to Drupal. Maybe ill use a css solution in the short term.

Thanks for all your help.

WorldFallz’s picture

One last suggestion, try:

<?php if ($title && arg(0) = 'admin'): ?>
jdln’s picture

I get a blank page. Thanks anyway though.

WorldFallz’s picture

My bad there was a syntax error. Should be:

<?php if ($title && arg(0) == 'admin'): ?>
jdln’s picture

Again Im getting a blank page. Just to be specific, im replacing the contents of the h1 tags with code you suggested.

<?php if ($title): ?>
              <h1 class="title"><?php print $title; ?></h1>
            <?php endif; ?>

to

<?php if ($title): ?>
              <h1 class="title"><?php if ($title && arg(0) == 'admin'): ?></h1>
            <?php endif; ?>
WorldFallz’s picture

nope-- sorry I should have been more specific.

Replace:

<?php if ($title): ?>
  <h1 class="title"><?php print $title; ?></h1>
<?php endif; ?>

With:

<?php if ($title && arg(0) == 'admin'): ?>
  <h1 class="title"><?php print $title; ?></h1>
<?php endif; ?>
jdln’s picture

It works! Thanks so much. Looking at the php i think i understand what youve done but i couldn't have written it myself.

WorldFallz’s picture

excellent-- happy we got it sorted.

jonaflatooni’s picture

Wanted to say appreciate the code fix. Not understanding the correct syntax for php I was lost. I used this to remove the page titles as well as the contact form title as well. Cheers.

if ($title && arg(0) != 'node' && arg(0) != 'contact'):