3

I'm experiencing the following PHP error on a site running Structure (3.3.6), and am having some trouble debugging it.

The text of the error is:

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 106

Filename: views/index.php

Line Number: 45

It is being output inline in my entry tree like so:

Screenshot of error

The code on line 45 of structure's views/index.php is:

$add_url  = BASE.AMP.'C=content_publish'.AMP.'M=entry_form'.AMP.'channel_id='.$page['channel_id']
.AMP.'parent_id='.$eid.AMP.'template_id='.$site_pages['templates'][$eid];

(Line break added for readability)

I can't see anything unique/wrong with the entry that is triggering this notice, and Structure is otherwise working fine. The only real reason I want to clean it up is that it's visible to the client in the CP (not my server and I can't edit PHP error prefs unfortunately).

Has anyone seen this before/know how to fix this?

  • Have you tried the Debug Mode for Page Data yet? Sometimes that helps clear up errors. Make a backup before running it just in case. – Alex Kendrick Nov 29 '12 at 14:56
  • Thanks, have run it through debug mode but unfortunately the notice remains – Tom Davies Nov 29 '12 at 15:05
  • Feel free to post these types of questions to the official Structure Support site so we can help you quickly :) – Jack McDade Jan 4 '13 at 15:10
4

The culprit is probably $site_pages['templates'][$eid]. A couple of obvious things to check would be:

  • What's in the templates array? Find out with var_dump($site_pages['templates']);
  • Check where $eid is set.

It's a bit of a leap of faith, but since the error looks like it relates to a template that isn't there, is there any chance you've assigned that page to a template which has since been deleted?

| improve this answer | |
  • So this was so close to being correct it's uncanny. var_dump($site_pages['templates']) outputs a pretty massive multidimensional array, but following your hunch about templates I tried editing the Structure template field for the entry, and then changing it back again to the value I wanted and, boom! Fixed. From the look of things Structure was referencing the wrong template_id somehow, even though template_name was correct and the entry was rendering fine on the front end. Weird. Anyway, thanks Dom! – Tom Davies Nov 29 '12 at 15:16
  • No worries, glad to hear that sorted it. – Dom Stubbs Nov 29 '12 at 15:29
-3

If you really just want to suppress the error message, add an "@" before the PHP code wich is responsible for your error.

I think $site_pages['templates'] just does not have an index with number 106, so in this case you could change line 45 into:

$add_url  = BASE.AMP.'C=content_publish'.AMP.'M=entry_form'.AMP.'channel_id='.$page['channel_id'].AMP.'parent_id='.$eid.AMP.'template_id='.@$site_pages['templates'][$eid];

Please consider another option as this is not the best solution ;)

| improve this answer | |

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.