how to code breadcrumbs (php kohana framework)?
is this good way to code breadcrumbs?
- cr开发者_如何学运维eate table "categories" using mysql
- create after neccessary columns "parent_id" column
- 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
- 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
精彩评论