[fixed] start_level does not work

Forum rules
Only administrators can post or move items here.
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

a solution could be that

Code: Select all

   else if( $start_level > 1 ) {
        $tmp = $hm->sureGetNodeById($gCms->get_content_id());

        $arr = array();
        $arr2 = array();
        while( $tmp ) {
            $id = $tmp->get_tag('id');

            if( !$id ) break;
            $arr[$id] = $tmp;
            $arr2[] = $id;
            $tmp = $tmp->get_parent();
        }

        if( $start_level - 2 < count($arr) ) {
//$number is the place of the good $id in array $arr2
$number=count($arr)-($start_level-1);
            $id = $arr2[$number];

            $tmp = $arr[$id];

            if( $tmp->has_children() ) {
                $children = $tmp->get_children();
                foreach( $children as $one ) {
                    $rootnodes[] = $one;
                }
            }
        }
    }
Last edited by archeo on Sun Jul 05, 2015 9:55 pm, edited 1 time in total.
jce76350
Beta Tester
Beta Tester
Posts: 1953
Joined: Mon May 29, 2006 1:20 pm
Location: Rouen

Re: [open] start_level does not work

Post by jce76350 »

SVN Navigato/action.default.php @ 10076
I have on a web page
- Notice: Undefined offset: 2 in \modules\Navigator\action.default.php on line 226
- Notice: Undefined index: in \modules\Navigator\action.default.php on line 227
Jean-Claude Etiemble
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

What is the contain of this lines?
Last edited by archeo on Sun Jul 05, 2015 6:30 pm, edited 1 time in total.
jce76350
Beta Tester
Beta Tester
Posts: 1953
Joined: Mon May 29, 2006 1:20 pm
Location: Rouen

Re: [open] start_level does not work

Post by jce76350 »

@ archeo test the last rev 10079
Jean-Claude Etiemble
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

No warning message but no left menu with template "Top simple navigation + left subnavigation + 1 column" with level=1 but left menu with level >1.
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

I think we must reconsider the problem.
consider a menu with six level and a start_level=6. At level 6 the id in $arr2 array are for exemple :
id=36,id=35,id=34,id=33,id=14i,d=11
the id to select is the second id=35.
What append when we are on level 3?
The id in $arr2 array are
id=33, id=14, id=11
The id to select is always id=35 but at this level we have not the information.
So for all the levels of the menu we should calculate $arr2 array for the most deep child.
after compare start_level and count($arr)
if start_level < count($arr) : invert arr2, select id in position start_level-1 and construct the menu using $tmp
else do nothing.
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

After a good night's sleep, I think what I wrote above is not good with branching menus. So this code
SOLUTION 1

Code: Select all

   else if( $start_level > 1 ) {
        $tmp = $hm->sureGetNodeById($gCms->get_content_id());
        $arr = array();
        $arr2 = array();
        while( $tmp ) {
            $id = $tmp->get_tag('id');
            if( !$id ) break;
            $arr[$id] = $tmp;
            $arr2[] = $id;
            $tmp = $tmp->get_parent();
        }
       if( $start_level - 2 < count($arr) ) {
$number=count($arr)-($start_level-1);
            $id = $arr2[$number];
            $tmp = $arr[$id];
            if( $tmp->has_children() ) {
                $children = $tmp->get_children();
                foreach( $children as $one ) {
                    $rootnodes[] = $one;
                }
            }
        }
    }
or this other
SOLUTION 2

Code: Select all

   else if( $start_level > 1 ) {
        $tmp = $hm->sureGetNodeById($gCms->get_content_id());
        if( $tmp ) {
            $arr = array();
            $arr2 = array();
            while( $tmp ) {
                $id = $tmp->get_tag('id');
                if( !$id ) break;
                $arr[$id] = $tmp;
                $arr2[] = $id;
                $tmp = $tmp->get_parent();
            }
            if( $start_level <= count($arr2) or  count($arr2)==1) {
                $arr2 = array_reverse($arr2);
                $id = $arr2[$start_level-2];
                $tmp = $arr[$id];
                if( $tmp->has_children() ) {
                    // do childrenof this element
                    $children = $tmp->get_children();
                    foreach( $children as $one ) {
                        $rootnodes[] = $one;
                    }
                }
            }
        }
    }
Does the same job and mimics start_level in V1
Last edited by archeo on Wed Jul 08, 2015 10:14 am, edited 1 time in total.
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

Not fixed in the snapshop of this night.
"Top simple navigation + left subnavigation + 1 column" template text needs also to be update replacing all item "menu" by "Navigator"
and this "stupid start_level param" :) will be fixed
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

I think this is the good solution :

Code: Select all

else if( $start_level > 1 ) {
        $tmp = $hm->sureGetNodeById($gCms->get_content_id());
        if( $tmp ) {
            $arr = array();
            $arr2 = array();
            while( $tmp ) {
                $id = $tmp->get_tag('id');
                if( !$id ) break;
                $arr[$id] = $tmp;
                $arr2[] = $id;
                $tmp = $tmp->get_parent();
            }
            if( ($start_level-2) < count($arr2)) {
                $arr2 = array_reverse($arr2);
                $id = $arr2[$start_level-2];
                $tmp = $arr[$id];
                if( $tmp->has_children() ) {
                    // do childrenof this element
                    $children = $tmp->get_children();
                    foreach( $children as $one ) {
                        $rootnodes[] = $one;
                    }
                }
			}
        }
    }
test : start_level from 0 to 7 on menu level from 1 to 6 with branching menu
You can test with this data base http://ciavatti.free.fr/cmsv2/cmsrc1.sql(2).zip and I perform tests on my web site (menus with start_level 1,2 and 3 on the same page.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12678
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: [open] start_level does not work

Post by Dr.CSS »

If start_level will work with anything above 1 then it works as it should, imho, as there is no need to use start_level='1' that I can see and I've made hundreds of menus in the last 9+ years I've been using CMSMS...

The Menu manager and Navigator auto start on level 1, No..?
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [open] start_level does not work

Post by calguy1000 »

To my knowledge, The start_level parameter in Navigator currently works as it does in the MenuManager module. start_level must be >= 2.

There is no need to extend the functionality on this obscure, and difficult to understand option. And there is really no further need to spend time on it (it has already consumed too much time).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7759
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: [open] start_level does not work

Post by Rolf »

Is fixed in current snapshot.
Image
- + - + - + - + - + -
Latest CMSMS tutorial: FormBuilder WatchGuard
- + - + - + - + - + -
Did my post help you solving a problem at your (customers) website and it saved you many hours of work?
Great!! Buy me a cup of coffee in return as a small token of appreciation!
archeo
Forum Members
Forum Members
Posts: 104
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: [open] start_level does not work

Post by archeo »

calguy1000 wrote: There is no need to extend the functionality on this obscure, and difficult to understand option. And there is really no further need to spend time on it (it has already consumed too much time).
Perhaps, but it is a very powerfull parameter usefull on websites with a lot of pages. Thank you for your patience and for the time you consumed on.
Post Reply

Return to “Closed Issues”