首页 > 前端
【复制】TP常用标签
来源:TP课堂 时间:2021-12-18

首页:

  <title>{$web_title}</title>
  <meta name="keywords" content="{$web_keywords}" />
  <meta name="description" content="{$web_description}" />
  
  
   {include file="public/head"}



列表页:

<title>{$categoryData.seo_title}</title>
<meta name="keywords" content="{$categoryData.seo_keywords}"/>
<meta name="description" content="{$categoryData.seo_description}"/>


$cate_id=5;
$categoryData=Db::name('category')->find($cate_id);
if(empty($categoryData)){
            return alert('error','/',5);
        }
return view('',[
   'categoryData'=>$categoryData
]);


当前位置:

{volist name="$positionData" id="vo"}<a
            href="{:url('index/index/'.$vo.index_template,array('cate_id'=>$vo.id))}">{$vo.cate_name}
            ></a>{/volist}


 use app\model\Categorys;
 public function product()
    {
        $cate_id=input('cate_id');
        $categoryData=Db::name('category')->find($cate_id);
        if(empty($categoryData)){
            return alert('error','/',5);
        }
        $parent_id=2;
        $childrenCate=Db::name('category')->where('parent_id',$parent_id)->order('listorder asc')->select();

        $categorys=Db::name('category')->field('id,parent_id')->select();
         $category_model=new Categorys();
         $cateStr=$category_model->getChildrenIdStr($categorys,$cate_id);
         $cateStr=$cateStr.','.$cate_id;
        $archivesData=Db::name('archives')->where('cate_id','in',$cateStr)->order('id desc')->paginate(['list_rows'=> 20,'query'=>request()->param()]);


        return view('index/product',[
            'categoryData'=>$categoryData,
            'childrenCate'=>$childrenCate,
            'archivesData'=>$archivesData,
            'cate_id'=>$cate_id,
            'parent_id'=>$parent_id
        ]);
    }


ThinkPHP文章页常用代码、上一篇下一篇文章获取