#1 April 3, 2012 8:32am

benplum
Administrator
Registered: March 30, 2012
Posts: 54

Working With Navigation

There are a few different navigation structures in BigTree that you can utilize in your sites:

Navigation refers to the hierarchical tree structure of BigTree pages. The Main Navigation, or Top Level Nav, are pages that are direct children of the Home page. Sub Nav are pages that are direct children of any other page.

Breadcrumbs provide a direct, sequential path from the current page to the homepage, tracing back the hierarchical tree structure.

Menus are not actually related to the hierarchical tree structure. Instead they are settings that allow you to group together random pages that aren't necessarily near each other in the page tree, or even external links.

Drawing the Main Nav
To access the Main Nav use $cms->getNavByParent(0, 2). The first parameter is the ID of the parent page, in this case 'Home,' while the second parameter is how many navigation levels to return, in this case 2. A constant value 0 as the function's $parent parameter will return the same result regardless of the page context. BigTree will return an array of every top-level page:

Array (
    [1] => Array (
            [id] => 1
            [parent] => 0
            [title] => About
            [route] => about
            [link] => http://example.com/about/
            [new_window] =>
            [children] => Array (
                    [3] => Array (
                            [id] => 3
                            [parent] => 1
                            [title] => History
                            [route] => about/history/
                            [link] => http://example.com/about/history/
                            [new_window] => true
                            [children] => Array()
                    )
            )
    )
    [2] => Array (
            [id] => 2
            [parent] => 0
            [title] => Store
            [route] => store
            [link] => http://example.com/store/
            [new_window] =>
            [children] => Array ()
    )
)

This result can then be used in your template:


   

  •             [url=[/url]
                       

           
        [/*] 
   
    [/list]

Because BigTree does not markup its output, you are free to structure your code however you see fit. This can be styled to produce something like the main navigation used on bigtreecms.org.



Drawing the Sub Nav
When drawing page-specific navigation, you may need to know the top-level ancestor of the current page. To get that value, use $cms->getTopLevelNavigationId(). This will give you the ID of the correct top-level page:

$top = $cms->getTopLevelNavigationId();
$navigation = $cms->getNavByParent($top, 4);
Use it in conjunction with the loop above to produce a subnav sidebar, similar to what you see in thedocumentation.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.