paw.MoreLevels

Post Reply
kohbarg
Sr. Bludit
Posts: 33
Joined: Tue Jun 11, 2019 11:36 am
Has thanked: 2 times
Been thanked: 2 times

Has anyone already generated a 3-level navigation? How can I address the child-child element?Please ask for information and help.
Thank you.
SamBrishes
Master Bludit
Posts: 106
Joined: Tue Dec 25, 2018 8:07 pm
Been thanked: 3 times

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.
Post Reply