Page 2 of 2

Re: [open] start_level does not work

Posted: Sun Jul 05, 2015 4:07 pm
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;
                }
            }
        }
    }

Re: [open] start_level does not work

Posted: Sun Jul 05, 2015 5:22 pm
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

Re: [open] start_level does not work

Posted: Sun Jul 05, 2015 5:49 pm
by archeo
What is the contain of this lines?

Re: [open] start_level does not work

Posted: Sun Jul 05, 2015 5:53 pm
by jce76350
@ archeo test the last rev 10079

Re: [open] start_level does not work

Posted: Sun Jul 05, 2015 7:37 pm
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.

Re: [open] start_level does not work

Posted: Sun Jul 05, 2015 9:40 pm
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.

Re: [open] start_level does not work

Posted: Mon Jul 06, 2015 6:56 am
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

Re: [open] start_level does not work

Posted: Tue Jul 07, 2015 1:21 pm
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

Re: [open] start_level does not work

Posted: Thu Jul 09, 2015 8:15 am
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.

Re: [open] start_level does not work

Posted: Thu Jul 09, 2015 6:13 pm
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..?

Re: [open] start_level does not work

Posted: Thu Jul 09, 2015 6:19 pm
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).

Re: [open] start_level does not work

Posted: Tue Jul 14, 2015 12:53 pm
by Rolf
Is fixed in current snapshot.

Re: [open] start_level does not work

Posted: Wed Aug 05, 2015 5:06 pm
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.