Clark
Clark

Reputation: 2213

how to code breadcrumbs (php kohana framework)?

is this good way to code breadcrumbs?

  1. create 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.

Upvotes: 3

Views: 1439

Answers (2)

towfx
towfx

Reputation: 11

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

Upvotes: 1

Bill Karwin
Bill Karwin

Reputation: 562711

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

Upvotes: 1

Related Questions