I recently updated from 3.0 to 3.7. Lately I noticed that the links wrapper was being printed in nodes even if there were no links or tags. I'm referring to the following code.

  <?php if (!empty($content['field_tags']) || !empty($content['links'])): ?>
  <footer>
    <?php print render($content['field_tags']); ?>
    <?php print render($content['links']); ?>
  </footer>
  <?php endif; ?>

I will submit a patch that fixes this issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bisonbleu created an issue. See original summary.

bisonbleu’s picture

Title: condition for printing links in node.tpl.php isn't working properly » condition for printing links wrapper in node.tpl.php isn't working properly
Status: Active » Needs review
FileSize
654 bytes

Here is the patch. In it, I'm replacing the if statement with this one adapted from Bartik.

<?php
  // Only display the wrapper div if there are links or tags.
  $links = render($content['links']);
  $field_tags = render($content['field_tags']);
  if ($links || $field_tags):
?>
markhalliwell’s picture

Status: Needs review » Needs work
+++ b/templates/node/node.tpl.php
@@ -102,7 +102,12 @@
+    $links = render($content['links']);
+    $field_tags = render($content['field_tags']);
...
     <?php print render($content['field_tags']); ?>
     <?php print render($content['links']); ?>

No need to pass it through render() again below, just print the newly created rendered variables.

bisonbleu’s picture

Status: Needs work » Needs review
FileSize
833 bytes

Right. Here's a new patch as per recommendation in #3.

markhalliwell’s picture

Status: Needs review » Needs work

No... use the $links and $field_tags variables this patch creates.

bisonbleu’s picture

Status: Needs work » Needs review
FileSize
811 bytes

I think there should be an issue queue award for "Sleeping on the switch" because this one would make me a very serious contender!

Thanks for your patience @markcarver.

  • markcarver committed 07cae92 on 7.x-3.x authored by bisonbleu
    Issue #2831581 by bisonbleu: condition for printing links wrapper in...
markhalliwell’s picture

Status: Needs review » Fixed

Np :D ty!

Status: Fixed » Closed (fixed)

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