2 levels DB tree navigator

P4A_2_Levels_DB_Navigator: a tree menu navigation widget having 2 nested P4A_DB_Source as data sources.

Do you need P4A_2_Levels_DB_Navigator?

P4A_DB_Navigator is really useful when you need to draw a tree navigation structure stored on a database, relying on 2 tables (eg: categories and subcategories of a shop).

Features

  • expanded/collapsed tree
  • trim descriptions after some chars

Screenshots

Sample code

// the root db_source
$this->build("p4a_db_source", "cat");
$this->cat->setTable("categories");
$this->cat->setPk("id");
$this->cat->addOrder("description");
$this->cat->load();
 
// the nested db_source
$this->build("p4a_db_source", "subcat");
$this->subcat->setTable("subcategories");
$this->subcat->setPk("id");
$this->subcat->addOrder("description");
$this->subcat->load();
 
// the filter that syncronize the nested db_source when the root moves
$this->subcat->addFilter("category_id = ?", $this->cat->fields->id);
 
// the P4A_2_Levels_DB_Navigator
$this->build("P4A_2_Levels_DB_Navigator", "nav");
$this->nav->setRootSource($this->cat);
$this->nav->setRootDescription("description");
$this->nav->setNestedSource($this->subcat);
$this->nav->setNestedDescription("description");

now you can anchor your P4A_2_Levels_DB_Navigator in a P4A_Fieldset or where you want.

Code reference

Download

This contrib was initially sponsored by Orange021.

Authors

 
2-levels-db-tree-navigator.txt · Last modified: 2007/01/03 12:56
 
Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki