0

I get these sporadically on the content admin screens. These seem to be referencing fields that I do have in my templates, that are working just fine for those actual screens. I just don't get why this content admin screen would be looking for those values.

Here are the error messages:

•   Notice: Undefined property: stdClass::$field_pcast_fname in include() (line 64 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/node.tpl.php).
•   Notice: Undefined variable: messages in include() (line 13 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/comment-wrapper.tpl.php).
•   Notice: Undefined index: field_twithandle in include() (line 14 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).
•   Notice: Undefined variable: field_headshot in include() (line 24 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).
•   Notice: Undefined offset: 1 in include() (line 94 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).
•   Notice: Trying to get property of non-object in include() (line 94 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).

And for example, the field_twithandle code that's in my user-profile.tpl.php:

<?php if($user_profile['field_twithandle']) { ?> 
    <div class="profile_twitfollow">
        <a href="http://twitter.com/<?php print $field_twithandle[0]['value']; ?>" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @<?php print $field_twithandle[0]['value']; ?></a>
        <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
    </div>
<?php  } ?>

1 Answer 1

1

Try this, check to make sure it's set first:

<?php if (isset($field_twithandle[0]['value'])): ?>
<a href="http://twitter.com/<?php print $field_twithandle[0]['value']; ?>" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @<?php print $field_twithandle[0]['value']; ?></a>
<?php endif; ?>

The problem is that those values aren't set on some pages, which is why you're getting the error. So that's a fix for an undefined index error. You also have things like undefined variable, for which a fix could be like:

<?php if (isset($messages)): ?>
  /* Do stuff here with $messages */
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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