`使用嵌套集基于预定义路径检索页面

时间:2014-05-17 21:07:17

标签: php mysql content-management-system hierarchical-data nested-lists

我目前正在构建CMS,并打算使用Joe Celko的嵌套树集(MPTT)来检索分层数据,例如基于已定义路径的嵌套深层页面。例如 example.com/products/phone/specs。

我有一个类别表

cat_id    name        lft  rgt
1         products    1    18
2         phone       2    9
3         specs       3    4
4         gallery     5    6
5         price       7    8
6         laptop      10   17
7         specs       11   12
8         gallery     13   14
9         price       15   16
10

和页面表

page_id   name    content
1         specs   Here is the specification of the chosen phone
2         price   the price of chosen phone
3         specs   laptop spec
4         price   laptop price

此架构可在slqfiddle上找到 不幸的是,我不知道如何做到这一点,我从搜索在线示例得到的最接近的想法甚至celko的书确实假设你只想“检索单个路径”到节点的父节点。然而,我的用例要求我根据上面url设置的路径检索页面(并显示它)。 所以,我可以实现这一目标吗?欢迎所有宝贵的建议。感谢。

0 个答案:

没有答案