I was getting both page and article titles(duplicate) when displaying a node. On examination of node.tpl I see the code:

  <?php if(!empty($user_picture) || !$page || (!empty($submitted) && $display_submitted)): ?>
    <header class="clearfix<?php $user_picture ? print ' with-picture' : ''; ?>">
      <?php print $user_picture; ?>
      
      <?php print render($title_prefix); ?>
      <?php if ($title): ?>
        <h1<?php print $title_attributes; ?>>
          <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
        </h1>
      <?php endif; ?>
      <?php print render($title_suffix); ?>
 
      <?php if ($display_submitted): ?>
        <div class="submitted"><?php print $submitted; ?></div>
      <?php endif; ?>

    </header>
  <?php endif; ?>

I had opted for "Display author and date information" for article content types so (!empty($submitted) && $display_submitted)) is true so it was entering the if statement and printing the title. When I turned off submitted the article title disappeared.

Should the print title section not be wrapped in an if (!$page)? ie:

  <?php if(!empty($user_picture) || !$page || (!empty($submitted) && $display_submitted)): ?>
    <header class="clearfix<?php $user_picture ? print ' with-picture' : ''; ?>">
      <?php print $user_picture; ?>

      <?php if (!$page): ?>
        <?php print render($title_prefix); ?>
        <?php if ($title): ?>
          <h1<?php print $title_attributes; ?>>
            <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
          </h1>
        <?php endif; ?>
        <?php print render($title_suffix); ?>
      <?php endif; ?>
      <?php if ($display_submitted): ?>
        <div class="submitted"><?php print $submitted; ?></div>
      <?php endif; ?>

    </header>
  <?php endif; ?>

I am surprised that no one else has noticed this so I wont be surprised if I am wrong!

CommentFileSizeAuthor
#11 title_duplicates.pdf406.25 KBjchristophe

Comments

Jeff Burnz’s picture

Assigned: Unassigned » Jeff Burnz

Hmmm, I need to check this out. I'll post a fix etc shortly.

Jeff Burnz’s picture

I posted a fix but actually I missed more commits, wow, bad man, posting update shortly

Jeff Burnz’s picture

OK, this is a missed commits before release, so shit bugger, my bad...

There are several updates needed here - first in node tpl and then in page tpl - the idea is to print the title for nodes in node tpl always, and never in page tpl when viewing a node, this preserves the outline or page structure in HTML5.

node.tpl.php - use this instead:

<article id="article-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $unpublished; ?>

  <?php print render($title_prefix); ?>
  <?php if(!empty($user_picture) || $title || (!empty($submitted) && $display_submitted)): ?>
    <header class="clearfix<?php $user_picture ? print ' with-picture' : ''; ?>">

      <?php print $user_picture; ?>

      <?php if ($title): ?>
        <h1<?php print $title_attributes; ?>>
          <?php if ($page): ?>
            <?php print $title; ?>
          <?php elseif (!$page): ?>
            <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
          <?php endif; ?>
        </h1>
      <?php endif; ?>

      <?php if ($display_submitted): ?>
        <div class="submitted"><?php print $submitted; ?></div>
      <?php endif; ?>

    </header>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <div<?php print $content_attributes; ?>>
  <?php
    hide($content['comments']);
    hide($content['links']);
    print render($content);
  ?>
  </div>

  <?php if ($links = render($content['links'])): ?>
    <nav class="clearfix"><?php print $links; ?></nav>
  <?php endif; ?>

  <?php print render($content['comments']); ?>

</article>

page.tpl.php - the page title and "header" section is totally rewritten:

      <?php $tag = $title ? 'section' : 'div'; ?>
      <<?php print $tag; ?> id="main-content" role="main">

        <?php print render($title_prefix); ?>
        <?php if ($title && !isset($node)): ?>
          <header>
            <h1 id="page-title"><?php print $title; ?></h1>
          </header>
        <?php endif; ?>
        <?php print render($title_suffix); ?>

        <?php if ($primary_local_tasks || $secondary_local_tasks || $action_links): ?>
          <div id="tasks" class="clearfix">
            <?php if ($primary_local_tasks): ?>
              <ul class="tabs primary clearfix"><?php print render($primary_local_tasks); ?></ul>
            <?php endif; ?>
            <?php if ($secondary_local_tasks): ?>
              <ul class="tabs secondary clearfix"><?php print render($secondary_local_tasks); ?></ul>
            <?php endif; ?>
            <?php if ($action_links = render($action_links)): ?>
              <ul class="action-links clearfix"><?php print $action_links; ?></ul>
            <?php endif; ?>
          </div>
        <?php endif; ?>

        <div id="content"><?php print render($page['content']); ?></div>

        <?php print $feed_icons; ?>

      </<?php print $tag; ?>>

There is also a bit of extra CSS that should have been committed, for navigation.css this slots in around line 223:

/* tasks */
div#tasks {
  margin-top: 20px;
  margin-bottom: 10px;
  padding: 0;
}
.not-front.page-node div#tasks {
  margin-top: 0;
}

and in page css we need to add div#tasks to the very first declaration in that file, i.e.

.block-inner,
.breadcrumb,
.region-help,
.messages,
#main-content > header,
div#tasks,
#attribution {
    margin-left: 20px;
    margin-right: 20px;
}
Jeff Burnz’s picture

Status: Active » Fixed

I have committed these fixes to the dev version, so they will show when that is rebuilt (every 12 hours or so), I want to test this just a fraction more, if OK I will release a new version because this is a really bad miss and I too cannot believe no one else has reported it!

jimboh’s picture

Great and thanks for your very speedy response!

alexandersluiter’s picture

I'm seeing the same thing on a site I'm developing. Keep us posted :)

Jeff Burnz’s picture

Version: 7.x-2.1 » 7.x-2.x-dev
justinledwards’s picture

Is this fixed in the stable version?

Status: Fixed » Closed (fixed)

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

vildoc’s picture

not fixed in the stable version.

jchristophe’s picture

StatusFileSize
new406.25 KB

Hi Jeff,

Has this issue been fixed in v7.x-2.2 as I'm still getting duplicate titles on articles and polls with Drupal 7.9 and AT Core 7.x-2.1.
I've updated the code as detailed above but no luck. Any idea? This does not happen with newly created custom content types.

Thank in advance,
JS

bkosborne’s picture

#3 fixed the issue for me...

Jeff Burnz’s picture

It should be fixed in the DEV version, I will be cutting new releases for the themes with updates at the end of this week.

jchristophe’s picture

And you are right... It does after all when I load the right copy of the theme... My bad...
Thanks for replying...
JS

jchristophe’s picture

Thanks for the update Jeff and sorry for the trouble... Great theme... Will be waiting for next release...
Thanks again, JS

iGetcha’s picture

Issue tags: +theme, +node, +sky, +articles, +duplicate titles

#3 worked for us too on http://www.cybermidnight.com Thanks Jeff!