P4A_2_Levels_DB_Navigator: a tree menu navigation widget having 2 nested P4A_DB_Source as data sources.
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).
// 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.
This contrib was initially sponsored by Orange021.