Page 1 of 1

paw.MoreLevels

Posted: Sat Jun 15, 2019 8:29 pm
by kohbarg
Has anyone already generated a 3-level navigation? How can I address the child-child element?Please ask for information and help.
Thank you.

Re: paw.MoreLevels

Posted: Sun Jun 16, 2019 9:31 am
by SamBrishes
Hellow,

I guess, there is currently no frontend theme, which supports a multi-level navigation using paw.MoreLevels. But I'm using this plugin on my own, on a small internal project, and wrote the following snippet for a multi-level Table of Content Widget.

Note: This solution works ONLY if you're ordering the content after the position (and depth) on your own (or if you order the respective $data array manually, of course).

Code: Select all

$data = $pages->getPublishedDB();           // Get published Page Keys
$count = 0;
do{
    $item = new Page(current($data));       // Get current Page Object
    $next = next($data);                    // Get next Page Key
            prev($data);                    // Reset $data Array
    
    
    // Just a Basic Example
    echo str_repeat("- ", $count) . $item->title() . "<br />";
    if(substr_count($next, "/") > $count){
        $count++;
    } else if(substr_count($next, "/") < $count){
        $count -= ($count - substr_count($next, "/"));
    }
} while(next($data));
The result looks like this:

Image

So, in fact, you need to create an own respective loop, fetch each page on your own and use the respective methods of the "Page" class to create your link / URL working.

Sincerely,
Sam.