1

Since this morning, I get this message on my website.

It says the error is on line 7 in my template file, but when I look at the line 7 the code on it is <?php if (!$page): ?>.

My template file looks like the following.

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>">
  <div class="node-inner">
    <?php if (!$page): ?>
      <h2<?php print $title_attributes; ?>>      
      <?php if (($type == "article") && ($node->field_add_taxonomy_tag_articles[$node->language][0]['tid'] == 26)): ?>
        <a href="/discoveries#node-<?php print $node->nid; ?>"><?php print $title; ?></a></h2>
      <?php else:?>
        <a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
      <?php endif; ?>
    <?php endif; ?>
    <?php print $user_picture; ?>
    <?php if ($display_submitted): ?>
      <span class="submitted"><?php print $date; ?> Ñ <?php print $name; ?></span>
    <?php endif; ?>
    <div class="content">
      <?php
        hide($content['comments']);
        hide($content['links']);
        print render($content);
      ?>
      <?php if (!empty($content['links'])): ?>      
        <span class="links">
          <?php print render($content['links']); ?>
        </span>
      <?php endif; ?>
    </div>      
    <?php if (!empty($content['links']['terms'])): ?>
      <div class="terms">
        <?php print render($content['links']['terms']); ?>
      </div>
    <?php endif;?>  
  </div> <!-- /node-inner -->
</div> <!-- /node-->
<?php print render($content['comments']); ?>'
3
  • Try <?php if ($page): ?> – Digital fire Dec 13 '12 at 15:09
  • if i do what you said, the notice message doesn't appear but all the titles of the articles on my page disapear – Kaylan Brunet Dec 13 '12 at 15:19
  • now it says that the same notice msg is about this : if ( ($type == "article") && ($node->field_add_taxonomy_tag_articles[$node->language][0]['tid']==26) ): ?> – Kaylan Brunet Dec 13 '12 at 15:23
5

The line that is causing that error message is the following one.

<?php if (($type == "article") && ($node->field_add_taxonomy_tag_articles[$node->language][0]['tid'] == 26)): ?>

'und' is the value for the constant LANGUAGE_NONE, which is used for $node->language, when the node is language-neutral.

When you want to obtain the value of a field, you should use field_get_items(), as in the following code.

<?php $items = field_get_items('node', $node, 'field_add_taxonomy_tag_articles'); ?>
<?php if (($type == "article") && ($items[0]['tid'] == 26)): ?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.