How do I hide the date and author information on pages? I have turned it off in the global settings but it stays on the page.

Comments

tnats’s picture

I had to make sure that I had enabled write access to /sites/default/files for it to work.

CFW’s picture

Thanks, for your suggestion.
I enabled write access (0777) on /sites/default/files but this doesn't solve the problem.

jansselt’s picture

Version: 6.x-1.4 » 7.x-1.5
Component: Miscellaneous » User interface

The date on the left hand side is is generated by the following code in the node.tpl.php

<div class="date">
  <div class="day"><?php print format_date($node->created, 'custom', 'd') ?></div>
  <div class="month-and-year">
      <div class="month"><?php print format_date($node->created, 'custom', 'M') ?></div>
      <div class="year"><?php print format_date($node->created, 'custom', 'Y') ?></div>
  </div>
</div>

To make it only show for blog posts and not on normal/information pages I added the following which seems to do the job for now until an option is built in to turn this off...

<?php if ($node->type=='blog'): ?>		
  <div class="date">
    <div class="day"><?php print format_date($node->created, 'custom', 'd') ?></div>
    <div class="month-and-year">
      <div class="month"><?php print format_date($node->created, 'custom', 'M') ?></div>
      <div class="year"><?php print format_date($node->created, 'custom', 'Y') ?></div>
    </div>
  </div>
<?php endif; ?>

Hope that helps!

CFW’s picture

Thanks, it works perfect now.

I also hide the author, see blow:

    	<?php if ($node->type=='blog'): ?>
      <div class="date">
        <div class="day"><?php print format_date($node->created, 'custom', 'd') ?></div>
        <div class="month-and-year">
          <div class="month"><?php print format_date($node->created, 'custom', 'M') ?></div>
          <div class="year"><?php print format_date($node->created, 'custom', 'Y') ?></div>
        </div>
      </div>
      <?php endif; ?>
    	<?php if ($node->type=='blog'): ?>      
      <?php if ($name): ?>
          <div class="user-name"><?php print $name; ?></div>
      <?php endif; ?>
      <?php endif; ?>

Is this the right way? Thanks again!

jansselt’s picture

Well, I don't want to call it the right way. Will it work? For now, yes. Is it the way this should be done? In my opinion, no.

This should be a built in option on the theme. The problem with the solution I supplied and your solution to the author information is that if the theme ever gets updated, its going to overwrite this fix. We would have to apply it again after updating. Not the end of the world, but not the proper way to be handling this.

Of course you could just neglect any future updates.

Jarek Foksa’s picture

There is a more elegant way to do this, I just had to wrap the date and user name with if ($display_submitted) statement:


    <div class="node-meta">
      <?php if ($display_submitted): ?>
        <div class="date">
          <div class="day"><?php print format_date($node->created, 'custom', 'd') ?></div>
          <div class="month-and-year">
            <div class="month"><?php print format_date($node->created, 'custom', 'M') ?></div>
            <div class="year"><?php print format_date($node->created, 'custom', 'Y') ?></div>
          </div>
        </div>
        <div class="user-name"><?php print $name; ?></div>
      <?php endif; ?>
      <?php print render($content['links']['comment']); ?>
    </div> <!-- /.node-meta -->

This way you can enable or disable date and author information in content type settings, under the "Display settings" tab. I will commit the fix in a moment.

Jarek Foksa’s picture

Status: Active » Fixed

Fixed in release 1.6

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

eku28’s picture

Version: 7.x-1.5 » 7.x-1.8
Status: Closed (fixed) » Needs work

This is still a problem, turning off the display settings doesn't work. Is the only fix still going into the node.tpl.php? I'm having this same problem with every drupal 7 theme.

eku28’s picture

Status: Needs work » Fixed

My previous post is actually a different problem: the date and author information (and then the title) are appearing underneath the content page in the same font size.

It's kind of weird because after a few screen refreshes then a separate "Read more" appears underneath the duplicate title and then again underneath the date and author information, so I'll end up with 3 "Read more's" on one content page. But this is using an acquia drupal stack and it's not happening with xampp or wampserver drupal 7 installation.

I'll keep this acquia stack installation for a while to try to learn how to fix a problem like this.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

strauch’s picture

Version: 7.x-1.8 » 6.x-1.8

For 6.x-1.8 this solution doesn't work, i have this solution:

    <div class="node-meta">
	<?php if ($submitted): ?>
		<div class="date">
		<div class="day"><?php print format_date($node->created, 'custom', 'd') ?></div>
		<div class="month-and-year">
			<div class="month"><?php print format_date($node->created, 'custom', 'M') ?></div>
			<div class="year"><?php print format_date($node->created, 'custom', 'Y') ?></div>
		</div>
	</div>
          <div class="user-name"><?php print $name; ?></div>
      <?php endif; ?>
    </div> <!-- /.node-meta -->
did1979’s picture

Status: Closed (fixed) » Active

I would like to print the taxonomy terms instead of the date (or the username).

But when I try with the variable $terms in the node.tpl.php I am getting an error : undefined variable $terms... in node.tpl.php

thanks.

did1979’s picture

Status: Active » Closed (fixed)

I re-close this issue becaus I've opened a new one on D7 1.8 version.
Did