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?

3
  • 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. Commented Nov 29, 2012 at 14:56
  • Thanks, have run it through debug mode but unfortunately the notice remains Commented Nov 29, 2012 at 15:05
  • Feel free to post these types of questions to the official Structure Support site so we can help you quickly :) Commented Jan 4, 2013 at 15:10

2 Answers 2

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?

2
  • 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! Commented Nov 29, 2012 at 15:16
  • No worries, glad to hear that sorted it. Commented Nov 29, 2012 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 ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.