PHP Doctrine 1.2 Using Nested Set , how moving a node in different situation -


i use nested set doctrine 1.2.

here example.

i got tree

category 1    category 1.1    category 1.2    category 1.3    category 1.4 category 2    category 2.1       category 2.1.1       category 2.1.2       category 2.1.3 

situation
1 - how can move category 1.3 on top of category 1.1
2 - how can move category 1.4 inside category 1.3
3 - how can move 2.1 , child inside category 1 , next category 1.1

situation 1 give me:

category 1    category 1.3    category 1.1    category 1.2    category 1.4 ... 

situation 2 give me:

category 1    category 1.1    category 1.2    category 1.3       category 1.4 ... 

situation 3 give me:

category 1    category 1.1    category 2       category 2.1          category 2.1.1          category 2.1.2          category 2.1.3    category 1.2    category 1.3    category 1.4 

see http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_node_interface.html

please note original question not entirely correct: in case 3) said wanted move 2.1 inside category 1, according sample have given scenario, wanted move of category 2 inside category 1.

let's names mentioned (category 1.1) actual id of category, here scenarios describing:

$cat11 = doctrine_core::gettable("category")->find("category 1.1"); $cat13 = doctrine_core::gettable("category")->find("category 1.3"); $cat14 = doctrine_core::gettable("category")->find("category 1.4"); $cat21 = doctrine_core::gettable("category")->find("category 2.1"); 

moving 1.3 on top of category 1.1:

$cat13->getnode()->moveasprevsiblingof($cat11); 

moving 1.4 inside 1.3:

$cat14->getnode()->moveasfirstchildof($cat13); 

moving of category 2 inside category 1, next category 1.1:

$cat21->getnode()->moveasnextsiblingof($cat11); 

don't forget save categories after manipulation, e.g. $cat11->save(). it's sufficient save category manipulating.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -