CodeCanyon Hierarchical Category Management 11555976

CodeCanyon Hierarchical Category Management 11555976

CodeCanyon Hierarchical Category Management 11555976
PHP Script \ Project Management Tools
Categories \ Category \ Tree \ Traversal \ Subcategories \ Sucategory \ Preorder

PHP Script - Hierarchical Category Management 11555976 by hockic @ CodeCanyon

PHP Script \ Project Management Tools

Last Update: 26 May 15; High Resolution: Yes; Compatible Browsers: IE6, IE7, IE8, IE9, IE10, IE11, Firefox, Safari, Opera, Chrome; Files Included: HTML, PHP, SQL; Software Version: PHP 5.x, PHP 5.0 - 5.2, PHP 5.3, PHP 5.4, PHP 5.5, MySQL 5.x.

What is it?
Nested sets or Nested Set Model is a way to effectively store hierarchical data in a relational table. The main features are.

- Generation of select elements for forms

- Generation of lists (ul) consistent with Twitters Bootstrap framework

- Generation of raw nested (multidimensional) arrays so everyone can extend the script if needed without much trouble

As an bonus you get a Database class which makes use of PHP’s PDO for communication with the database. You can
easily get rid of it and implement your own database class.

Example #1: Creating nodes
The following code
// $root stores the id of the new node
$root = Mpttfactory()->create_root('Root node');
Mpttfactory()->create_child('Child node 1', $root);
Mpttfactory()->create_child('Child node 2', $root);
$child = Mpttfactory()->create_child('Child node 3', $root);
Mpttfactory()->create_child('Child node 4', $root);
Mpttfactory()->create_child('Child node 5', $root);
$sibling = Mpttfactory()->create_child('Child of child', $child);
Mpttfactory()->create_sibling('Sibling of child', $sibling);

Please analyze the code carefully…it will generate a data structure similar to the one on the screenshot bellow.

Example #2: Generating form elements

To make a select element simply pass the id of the desired node to the factory method and then call as_select() on the returned object

// Calling as_select will generate a valid select element
$root = 1;
echo Mpttfactory($root)->as_select('node_id');

Example #3: Getting the path of a node
// Calling get_path will generate a path to the desired node
echo Mpttfactory()->get_path(7);
You can than print the path with a simple loop.

[1] => Array
[id] => 1
[title] => Root node
[lft] => 1
[rgt] => 16
[4] => Array
[id] => 4
[title] => Child node 3
[lft] => 6
[rgt] => 11
[7] => Array
[id] => 7
[title] => Child of child
[lft] => 7
[rgt] => 8
Example #4: Deleting
To delete a node and it’s chidlren simply call the delete method and pass the id of the node you want to delete to it

// don't forget to do some validation after you get the id
$node_id = $_POST['node_id'];
Mpttfactory()->delete_id($node_id); ?>
Example #4: Check if node is leaf
A leaf node is a node which has no child nodes. Checking this factor can be usefull if you want the user to specify exactly what’s requested from him.

// don't forget to do some validation after you get the id
$node_id = $_POST['node_id'];
if( Mpttfactory()->is_leaf($node_id) )
// it is leaf .. do whatever you want
// it has child nodes, show an error message
Example #4: Configuration
There is a number of things you can do to make the returned list more suited for your purposes. Please take a look at the config parameters bellow.

echo Mpttfactory(array('only_leaf' => TRUE, 'limit' => 5))->as_select('node_id');
List of configuration parameters, their description, default and expected values


boolean (true/false)
Select only leaf nodes from the database?

boolean (true/false)
Make nodes with children unselectable when using as_select()?

Limit the number of returned nodes (only usefull in combination with the only_leaf parameter)

` `(four spaces)
The bit of text that makes depth of the node visible in select elements


Sign that is prepended to the title of leaf items


Sign that is prepended to the title of non-leaf items

Complete list of functions and their description

Returns raw array

Creates a multi-level menu compatible with the Bootstrap css framework

Creates a HTML form select element of the whole tree

Creates a new child node of the node with the given id

Creates a root node

Creates a new sibling next to the given node

Deletes a node and all it’s children

Sets config and returns Mptt object

Gets items depending on provided criteria and stores them in a local array

Gets an object with all data of a node

Gets a array containing the path to defined node

Checks whether the node is a descendant of another

Checks whether the node is leaf or not (A node is leaf when it has no child nodes)

If you have any questions before buying, please don’t hesitate to send me contact me.

Screener - Lightweight Screen Capture; Korum - Kohana-Based Forum.

Keywords: categories, categories management, category, Category Hierarchy, category tree, Hierarchical categories, infinite categories, mptt, preorder tree traversal, subcategories, sucategory.

Tags: Categories, Category, Hierarchical, Management

Premium CodeCanyon Hierarchical Category Management 11555976 WordPress Themes, Website Templates, Mobile Themes, Flash Templates & Scripts from creative professional designers. Full details of CodeCanyon Hierarchical Category Management 11555976 for digital design and education. CodeCanyon Hierarchical Category Management 11555976 desigen style information or anything related.


Add Comments:
Enter Code: *