Home >Backend Development >PHP Tutorial >TP5 code to implement website breadcrumb navigation

TP5 code to implement website breadcrumb navigation

不言
不言Original
2018-08-20 16:12:043337browse

The content of this article is about the code for TP5 to implement website breadcrumb navigation. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Breadcrumb navigation or current location

//面包屑导航
public function position($cid){//传递当前栏目id
static $pos=array();//创建接受面包屑导航的数组
if(empty($pos)){//哦,这个就比较重要了,如果需要把当前栏目也放到面包屑导航中的话就要加上
$cates=db(‘cate’)->field(‘id,cate_name,pid,cate_attr’)->find($cid);
$pos[]=$cates;
}
$data=db(‘cate’)->field(‘id,cate_name,pid,cate_attr’)->select();//所有栏目信息
$cates=db(‘cate’)->field(‘id,cate_name,pid,cate_attr’)->find($cid);//当前栏目信息
foreach ($data as $k => $v) {
if($cates[‘pid’]==$v[‘id’]){
$pos[]=$v;
$this->position($v[‘id’]);
}
}
return array_reverse($pos);
}

Related recommendations:

php implementation of breadcrumb navigation example sharing,

CSS3 making circular style breadcrumbs code implementation steps

The above is the detailed content of TP5 code to implement website breadcrumb navigation. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn