#172 ✓resolved
semias

3rd level menu error

Reported by semias | March 11th, 2011 @ 03:21 AM | in 5.0.4 (closed)

Error. Appears sometimes when loading a third level menu structure.

Fatal error: Call to undefined method stdClass::trail() in /[server/site]/saf/lib/GUI/MenuItem.php on line 138

Cause: This has to do with the build-up of the menu tree in the SAF, /saf/lib/GUI/menu.php. In here, the sitellite_page table is loaded, with GROUP BY below_page.
Suppose we have the following (CASE 1).

page_id | below_page
home |
section | home
page | section

This will be loaded in this order and gives no problems. However, when we rename section to “a_section”, the order of the results will be this (group by below_page) (CASE 2):

home |
page | a_section
a_section | home

The TREE table, contains fields “parent” and “children”. When we are in case 2, page will have parent “a_section”. However, the page a_section is not loaded at that time, so a StdClass will be loaded instead of a MenuItem. (function &addItem). This StdClass causes the errors.

Fix:
In function initTree, change the stdClass to a valid MenuItem.

foreach ($tree as $k => $v) {

        if ($v->{$this->listcolumn} == 'no') {
            continue;
        }

// Start: SEMIAS EDIT. P Hagens. 13 01 2011. Fix error in menu structure. // if ($v->{$this->refcolumn} && ! isset ($this->{'items_' . $v->{$this->idcolumn}}->parent)) {

        if ($v->{$this->refcolumn}) {

            $ref = $v->{$this->refcolumn};
            $parent = $this->{'items_' . $v->{$this->idcolumn}}->parent;

            // When parent is of type StdClass, no id is set.
            // Below: fix this and make it type MenuItem
            if(!$parent->{$this->idcolumn}) {
                // link the parent attr to the parent object
                $this->{'items_' . $v->{$this->idcolumn}}->parent =& $this->{'items_' . $ref};

                // link the children list to the child object
                $this->{'items_' . $ref}->children[] =& $this->{'items_' . $v->{$this->idcolumn}};
            }

        }
    }

// END: SEMIAS EDIT

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Sitellite web content management system.

People watching this ticket

Pages