1. First understanding of what is breadcrumb navigation
You can see that the crumbs are actually all the superior categories of the current viewing article a simple classification list is generally composed of ID name PID so it can be recursively queried
The following code is based on the thinkphp
Public function Class ($id) {
$res = $this->gettree ($id);//
Dump (Array_reverse ($res));//The result flashback
}
The Public Function Gettree ($id) {
static $res = Array ();//static variable does not disappear for each initialization of metadata
$info = M (' Ushop_class ')-> Field (' Id,pid,name ')->find ($id);
$res [] = $info;
if ($info [' pid ']>0] {//pid is greater than 0 must be subordinate classification
$this->gettree ($info [' pid ']);//recursive return
$res;
}
}
The returned category spanning tree plus the current article name can be used in the foreground