Hi,
I have the following tree structure using nested sets with lft & rgt values.
node
node
node
node
node (selected)
node
node
node
node
I'd like to build a navigation so that the tree is expanded, only to the path of the selected node, and non relevant nodes are collapsed/hidden.
Using the above method, the tree would be outputted as follows:
node
node
node
node (selected)
node
node
node
is this possible using php/mysql? If any sql gurus can help build a query I'd be most appreciative.?
I don't mind if I need an extra query per level, its probably only going to be 4 or 5 levels deep at most...
Overview of the nodes table:
--
-- Table structure for table `exp_node_tree_1`
--
CREATE TABLE `exp_node_tree_1` (
`node_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`lft` mediumint(8) unsigned DEFAULT NULL,
`rgt` mediumint(8) unsigned DEFAULT NULL,
`moved` tinyint(1) NOT NULL,
`label` varchar(255) DEFAULT NULL,
`entry_id` int(10) DEFAULT NULL,
`template_path` varchar(255) DEFAULT NULL,
`custom_url` varchar(250) DEFAULT NULL,
`extra` varchar(255) DEFAULT NULL,
PRIMARY KEY (`node_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;
--
-- Dumping data for table `exp_node_tree_1`
--
INSERT INTO `exp_node_tree_1` VALUES(1, 1, 12, 0, 'Home', 1, '0', '/', '');
INSERT INTO `exp_node_tree_1` VALUES(5, 10, 11, 0, 'About Us', 2, '4', '', '');
INSERT INTO `exp_node_tree_1` VALUES(6, 6, 9, 0, 'Team', 3, '5', '', '');
INSERT INTO `exp_node_tree_1` VALUES(7, 3, 4, 0, 'Contact Us', 4, '4', '', '');
INSERT INTO `exp_node_tree_1` VALUES(8, 7, 8, 0, 'Awards', 5, '5', '', '');
INSERT INTO `exp_node_tree_1` VALUES(10, 2, 5, 0, 'New Page', 6, '4', '', '');
Thank you!