[TOC]
# <head>
标题,关键词,关键描述,css/js路径
~~~
<title>{if isset($SEO['title']) && !empty($SEO['title'])}{$SEO['title']}{/if}{$SEO['site_title']}</title>
<meta name="keywords" content="{$SEO['keyword']}">
<meta name="description" content="{$SEO['description']}">
<link rel="stylesheet" href="{APP_PATH}/css/xstyle.css">
~~~
css,js路径用 `{APP_PATH}` ,站点根目录
# 站点根目录
~~~
{siteurl($siteid)}/
{APP_PATH}
~~~
# 碎片
头部,底部,有些地方,比如电话等,可用碎片实现后台管理,全站通用
~~~
{pc:block pos="head"}{/pc}
~~~
> 以上代码的head,自定义
# 导航
~~~
{pc:content action="category" catid="0" num="25" siteid="$siteid" order="listorder ASC"}
<ul>
<li><a href="{siteurl($siteid)}/">网站首页</a></li>
{loop $data $r}
<li><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
</ul>
{/pc}
~~~
## 点击父分类,访问第一个子分类,以及调出子分类
~~~
{pc:content action="category" catid="0" num="25" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
//判断是否有子分类
{if strpos($r[arrchildid],",") === false}
<a href="{$r[url]}">{$r[catname]}</a>
{else}
{pc:content action="category" catid="$r[arrchildid]" num="1" siteid="$siteid" order="listorder ASC"}
{loop $data $v}
{php $newUrl = $v[url]}
{/loop}
{/pc}
<a href="{$newUrl}">{$r[catname]}</a>
{/if}
//子分类
<ul>
{pc:content action="category" catid="$r[arrchildid]" num="15" siteid="$siteid" order="listorder ASC"}
{loop $data $v}
<li>
<a href="{$v[url]}">{$v[catname]}</a>
</li>
{/loop}
{/pc}
</ul>
{/loop}
{/pc}
~~~
数据库参考
![](https://img.kancloud.cn/0a/f2/0af2efa4af88d7b756dc01b00e13d3a8_357x130.jpg)