开发者

how to code breadcrumbs (php kohana framework)?

开发者 https://www.devze.com 2023-01-11 06:37 出处:网络
is this good way to code breadcrumbs? cr开发者_如何学运维eate table \"categories\" using mysql

is this good way to code breadcrumbs?

  1. cr开发者_如何学运维eate table "categories" using mysql
  2. create after neccessary columns "parent_id" column
  3. if parent_id column have null value it means that this category is parent and if else this columns parent is a column with id which marked in "parent_id" column
  4. recursively query to "parent_id" column starting at current column and print category name.


Breadcrumbs are easier if you use other methods of storing hierarchical data.

See my presentation Models for Hierarchical Data with SQL and PHP for examples of alternatives:

  • Path Enumeration
  • Nested Sets
  • Closure Table


You want to check out Modified Preorder Tree Traversal modules

  • Sprig MPTT github.com/banks/sprig-mptt
  • Jelly MPTT github.com/AlexKupreev/jelly-mptt
  • v3 ORM MPTT github.com/kiall/kohana3-orm_mptt
  • v2 ORM MPTT dev.kohanaframework.org/projects/mptt
0

精彩评论

暂无评论...
验证码 换一张
取 消