0

So I am theming a View with a template in my theme folder.

I am getting this error message:

"Notice: Undefined offset: 1 in include()"

This is the code:

<?php print ($fields["title"]->content); ?>

I've tried adding an IF statement like below (is my syntax correct???) and clearing the cache but the issue persists:

<?php if ($fields["title"]->content) { print ($fields["title"]->content); } ?>

P.S. the field is printing, it's just that there is an error message displayed in addition.

Also, by the way, I am using views-view-fields.tpl.php

1 Answer 1

0

You need to use isset() to avoid such notices:

<?php if (isset($fields["title"])) { print ($fields["title"]->content); } ?>
4
  • Hi, thanks. I have applied this line but the error persists. I actually already tried this but just didn't mention in my post. Anything else I can try?
    – caustic
    Commented Mar 13, 2015 at 2:34
  • Oops. Made a small edit because the notice would still occur when there is no key 'title' in the $fields array.
    – montaigne
    Commented Mar 13, 2015 at 2:36
  • Hmm... i still get the error? I'm using: <?php if (isset($fields["title"])) { print ($fields["title"]->content); } ?>
    – caustic
    Commented Mar 13, 2015 at 2:39
  • When checking /admin/reports/dblog, Am getting Undefined offset: 1include() in node template file. this is the mentioned line in node tpl file. $selected_l2 = strip_tags($all_breadcrumb['breadcrumb']['1']);
    – steniya
    Commented Apr 24, 2017 at 7:44

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.