Class: Navigation extends Tree

Handles managing the navigation tree as a jstree-compatible json object. Items in the tree have the following structure:

{"data":"Title","attr":{"id":"page-id","sort":0}}

Item that have children will have an additional children property that is an array of other items.

Usage:

$n = new Navigation;
// $n->tree contains data from conf/navigation.tree

$n->add ('index');
$n->add ('blog', 'index');

$node = $n->node ('blog');
// {"data":"Blog","attr":{"id":"blog","sort":0}}

$path = $n->path ('blog');
// array ('index', 'blog')

$n->move ('blog', 'index', 'before');
$ids = $n->get_all_ids ();
// array ('blog', 'index')

$n->remove ('blog');

// save to conf/navigation.json or the file configured in global config
$n->save ();

Properties

No properties.

Methods

public __construct ($file)

Constructor method. Decodes the navigation tree from the specified file in JSON format, or defaults to conf ('Paths', 'navigation_json') if no file is specified.

public add ($id, $parent = false, $title = false)

Overrides Tree::add() to fetch the page title from the database if only the ID is passed.