到目前为止用到过的phpcms语法:
1、取栏目名称:
{$CATEGORYS[$catid][catname]}
{$CATEGORYS[$top_parentid][catname]}
2、取栏目地址:
{$CATEGORYS[$catid][url]}
3、取一级栏目:
1
2
3
4
5
6
|
{pc:content action=
"category"
catid=
"0"
num=
"5"
siteid=
"$siteid"
order=
"listorder ASC"
}
{loop
$data
$r
}
{/loop}
{/pc}
|
4、取带二级栏目的导航:
1
2
3
4
5
6
7
8
9
10
11
|
{pc:content action=
"category"
catid=
"0"
num=
"5"
siteid=
"$siteid"
order=
"listorder ASC"
}
{loop
$data
$r
}
{pc:content action=
"category"
catid=
"$r[catid]"
num=
"3"
siteid=
"$siteid"
order=
"listorder ASC"
}
{loop
$data
$v
}
{/loop}
{/pc}
{/loop}
{/pc}
|
加判断:
1
2
3
4
5
6
7
8
9
10
11
|
{pc:content action=
"category"
catid=
"0"
num=
"4"
siteid=
"$siteid"
order=
"listorder ASC"
}
{loop
$data
$r
}
<!--
$catid
==
$r
[catid]表示判断该栏目id是否等于栏目id-->
<!--
$top_parentid
==
$r
[catid]表示如果是二级栏目的情况下,判断顶级栏目是否等于栏目id-->
{
if
$catid
==
$r
[catid]||
$top_parentid
==
$r
[catid]}
<a href=
"{$r[url]}"
><div
class
=
"menu menu_sel"
>{
$r
[catname]}</div></a>
{
else
}
<a href=
"{$r[url]}"
><div
class
=
"menu"
>{
$r
[catname]}</div></a>
{/
if
}
{/loop}
{/pc}
|
5、取内容:
1
2
3
4
5
6
7
|
{pc:content action=
"lists"
catid=
"60"
order=
"listorder ASC"
num=
"3"
moreinfo=
"1"
page=
"$page"
}
{loop
$data
$key
$val
}
$val
[title]
{/loop}
{/pc}
|
灵活运用:
1
2
3
4
5
6
7
8
9
10
|
{pc:content action=
"lists"
catid=
"60"
order=
"listorder ASC"
num=
"3"
}
{loop
$data
$key
$val
}
{
if
$key
==
"106"
}
// {if $key=="$id"} $id是当前传过来id
<div
class
=
"aa"
style=
"width:880px;"
><a href=
"{$val[url]}"
> {
$val
[title]}</a></div>
{
else
}
<div
class
=
"aa"
style=
"width:880px ; display: none;"
><a href=
"{$val[url]}"
> {
$val
[title]}</a></div>
{/
if
}
{/loop}
{/pc}
|
1
2
3
4
5
6
7
8
9
|
{pc:content action=
"category"
catid=
"$top_parentid"
num=
"4"
siteid=
"$siteid"
order=
"listorder ASC"
}
{loop
$data
$r
}
{
if
$r
[catid]==
"38"
}
<li
class
=
"c-li li-sel"
><a href=
"{$r[url]}"
>{
$r
[catname]}</a></li>
{
else
}
<li
class
=
"c-li"
><a href=
"{$r[url]}"
>{
$r
[catname]}</a></li>
{/
if
}
{/loop}
{/pc}
|
6、判断是否为首页?
1
2
3
4
5
6
|
{
if
$top_parentid
==0}
//首页地址
<a href=
"{siteurl($siteid)}"
><div
class
=
"menu menu_sel"
>首页</div></a>
{
else
}
<a href=
"{siteurl($siteid)}"
><div
class
=
"menu"
>首页</div></a>
{/
if
}
|
7、取时间:(见上一篇随笔)
{$inputtime}
8、取浏览数:
1
2
3
|
span id=
"hits"
></span>次
<!--浏览数的js-->
<script language=
"JavaScript"
src=
"{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"
></script>
|
9、取上一篇和下一篇:
1
2
|
{
$previous_page
[title]}
{
$next_page
[title]}
|
10:截取
1
|
{php list (
$copyfrom
)=
explode
(
'|'
,
$v
[
'copyfrom'
])}{
$copyfrom
}
|
11:分页
1
2
|
{pc:content action=
"lists"
catid=
"60"
order=
"listorder ASC"
num=
"3"
moreinfo=
"1"
page=
"$page"
}
{/pc}
|
分页的地方加:{$pages}