我使用具有 lft 和 rgt 值的嵌套集具有以下树结构。
node
node
node
node
node (selected)
node
node
node
node
我想建立一个导航,以便树被展开,只到所选节点的路径,并且不相关的节点被折叠/隐藏。
使用上述方法,树将输出如下:
node
node
node
node (selected)
node
node
node
这可能使用 php/mysql 吗?如果有任何 sql 专家可以帮助构建查询,我将不胜感激。?
我不介意每个级别是否需要额外的查询,它可能最多只有 4 或 5 级深度......
节点表概述:
--
-- 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', '', '');
谢谢!