Lykos22 Posted January 16, 2015 Share Posted January 16, 2015 (edited) Hi, I'd like some help please. I'm trying to create the functionality for managing menu items, using nested sets. So far I have created the functionality for adding new nodes/menu items and also deleting them and works fine (INSERTING and DELETING). My problem is that I can't figure out how to do the UPDATE, i.e to move a node and its child nodes (if any) and set it as a child node, change the node/menu items order of display etc etc. I did a research on google, but wasn't friendly enough, perhaps I used and wrong keywords. Adnyway does anyone knows what pseudo - sql queries I must use and the logic in order to update nodes? thanks in advance Edited January 16, 2015 by Lykos22 Link to comment Share on other sites More sharing options...
justsomeguy Posted January 16, 2015 Share Posted January 16, 2015 What do you have so far, what database structure have you set up? Link to comment Share on other sites More sharing options...
Lykos22 Posted January 16, 2015 Author Share Posted January 16, 2015 What do you have so far, what database structure have you set up? Yes I have set up my database like this id (pk)menu_itemparent_id lftrgt and I have also created the functionality for adding nodes/menu items and deleting them. Now I'd like to do the update functionality, where basicly I can move nodes (and their child nodes too if any) everywhere inside the tree. for that I'm planning to use the nestedSortable plugin ( http://mjsarfatti.com/sandbox/nestedSortable/ ). Ijust can't figure out the "update nodes" logic, you know, what steps I should follow to do that. Could you give me some pseudo - sql queries that are used for this functionality? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 16, 2015 Share Posted January 16, 2015 It seems like moving a node would just mean changing the parent ID, right? So just a basic update query to update the parent ID would do it. Link to comment Share on other sites More sharing options...
Lykos22 Posted January 16, 2015 Author Share Posted January 16, 2015 It seems like moving a node would just mean changing the parent ID, right? So just a basic update query to update the parent ID would do it. No I'm afraid you 're probably refering to the adjaceny model. I use the nested sets model ( mptt ). This link explains each one pretty well. I would also have to change and the left (lft) and right (rgt) values not only from the node selected, but from the rest of the nodes of the tree too. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 16, 2015 Share Posted January 16, 2015 I've only looked at that structure briefly in the past, I'll need to review that for a while before I can help with your question. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now