我是尚丹丹,我的博客建好啦!欢迎大家光临!

【小知识】YXCms套模板

YXCms sdd 474℃ 0评论

1,详情页返回列表(返回当前分类列表页)

{$sorts[$pid][‘url’]}

2,列表页,发布时间格式

{date(“Y/m/d”,$vo[‘addtime’])}

{date(“Y/m”,$vo[‘addtime’])}

3,菜单里面判断第一个没有|,$flags用于判断循环序号

<?php $flags = 0;?>
{loop sorttree($sorts) $k1 $v1}
<a href=”{$v1[‘url’]}” > {if $flags!=0} | {/if}{$v1[‘name’]}</a>
<?php $flags ++ ;?>
{/loop}

 

4、菜单里面判断当前项样式,给首页添加当前态

<li><a href=”{url()}”  {if !$rootid} class=”current” {/if}>首页</a></li>

{loop sorttree($sorts) $k1 $v1}
<li><a href=”{$v1[‘url’]}” {if $rootid==$k1} class=”current” {/if} >{$v1[‘name’]}</a></li>
{/loop}

5、只显示网站名称(留言页不行)

<?php
$nameA = explode(“-“,$title);
$nameA = $nameA[count($nameA)-1];
?>

<a href=”{url()}” title=”{$nameA}”></a>

6,循环输出某个分类下的子分类

{loop $sorts $key $vo}
{if (strpos($vo[‘path’],’100002,’)!==false)}
<li class=”tab_list {if $id==$key} hover {/if}”><a href=”{$vo[‘url’]}” onfocus=”this.blur()” >{$vo[‘name’]}</a></li>
{/if}
{/loop}

只要子项不要孙项

{loop $sorts $key $vo}
{if (strpos($vo[‘path’],’100002,’)!==false && $vo[‘pid’] == ‘100002’)}
<li><a href=”{$vo[‘url’]}”>{$vo[‘name’]}</a></li>
{/if}
{/loop}

7、菜单只有一级

{loop sorttree($sorts) $k1 $v1}
<li {if $rootid==$k1} class=”active” {/if} ><a href=”{$v1[‘url’]}”>{$v1[‘name’]}</a></li>
{/loop}

8,列表最后一列加不同样式

<?php $flags = 0;?>

{loop $plist $vo}
<li {if $flags%4==3} class=”li_last” {/if}><a href=”{$vo[‘url’]}”><img src=”{$vo[‘picturepath’]}” title=”{$vo[‘title’]}”><span>{$vo[‘title’]}</span></a></li>
<?php $flags ++ ;?>
{/loop}

9,转码显示摘要。

<?php echo htmlspecialchars_decode($sorts[‘100035’][‘description’]);?>

<?php echo htmlspecialchars_decode($photo[‘content’]);?>

 

10、菜单里面,是否是外链

{loop sorttree($sorts) $k1 $v1}
<li {if $rootid==$k1} class=”active” {/if} ><a href=”{$v1[‘url’]}” {if $v1[‘method’]==”} target=”_black” {/if} >{$v1[‘name’]}</a></li>
{/loop}

 

11、不同时间格式

{date($news[‘addtime’],m-d)}或{date(“m-d”,date($vo[‘addtime’],Y-m-d))}

{date($news[‘addtime’],Y)}或{date(“Y”,date($vo[‘addtime’],Y-m-d))}

{date($vo[‘addtime’],d)}或{date(“d”,date($vo[‘addtime’],Y-m-d))}

{date($vo[‘addtime’],Y-m)}或{date(“Y-m”,date($vo[‘addtime’],Y-m-d))}

 

12、截取长度

{msubstr($vo[‘description’], 0, 130)}…

 

13,单页的内容

{page:{table=(page) field=(id,sort,content,edittime) where=(sort like ‘,000000,100001%’) limit=(1)}}
<?php echo htmlspecialchars_decode(msubstr($page[‘content’],0,214));?>
{/page}
{page:{table=(page) field=(id,sort,content,edittime) where=(sort like ‘%$key%’) limit=(1)}}
<?php echo htmlspecialchars_decode($page[‘content’]);?>
{/page}

14,取当前页封面图(单页)

{$sorts[$id][‘picture’]}

 

15,一级二级分类。如果有二级,在二级最上面加上’全部‘

{loop $sorts $key $vo}
{if (strpos($vo['path'],'100011,')!==false)}
{if ($vo['deep']- $sorts[100011]['deep'])==1}
<div class="subNav {if $rootid==$key} active {/if} {$vo['deep']}_{$sorts[100011]['deep']}*{$vo['nextdeep']}">

{$vo['name']}</div>
{if $vo['nextdeep']-$vo['deep']==1}
<ul class="navContent ">
<li><a href="{$vo['url']}" id="{$key}_{$id}" {if $id==$key} class="active"
{/if}>全部</a></li>
{/if}
{elseif ($vo['deep']-$sorts[100011]['deep'])==2}
<li><a href="{$vo['url']}" {if $id==$key} class="active" {/if}
{$vo['deep']}_{$sorts[100011]['deep']}*{$vo['nextdeep']}>
{$vo['name']}</a></li>{if $vo['deep']-$vo['nextdeep']==1}</ul>{/if}
{/if}
{/if}
{/loop}

322 321

 

16,一级二级分类。不管有没有二级,在一级里面都加上’全部‘,作为二级

{loop $sorts $key $vo}
{if (strpos($vo['path'],'100011,')!==false)}
{if ($vo['deep']- $sorts[100011]['deep'])==1}
<div class="{$vo['deep']}_{$sorts[100011]['deep']}*{$vo['nextdeep']}
subNav {if $rootid==$key} active {/if}">{$vo['name']}</div>
<ul class="navContent "><li><a href="{$vo['url']}" id="{$key}_{$id}"
{if $id==$key} class="active" {/if}>全部</a></li>
{elseif ($vo['deep']-$sorts[100011]['deep'])==2}
<li><a href="{$vo['url']}" {if $id==$key} class="active" {/if}
{$vo['deep']}_{$sorts[100011]['deep']}*{$vo['nextdeep']}>
{$vo['name']}</a></li>
{/if}
{if ($vo['deep']- $sorts[100011]['deep'])==1&&$vo['deep']-$vo['nextdeep']==0}
</ul>{/if}
{if ($vo['deep']- $sorts[100011]['deep'])==2&&$vo['deep']-$vo['nextdeep']==1}
</ul>{/if}

{/if}
{/loop}

323 320

转载请注明:尚丹丹的博客 » 【小知识】YXCms套模板

喜欢 (1)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(1)个小伙伴在吐槽
  1. 很好哦
    1112016-09-27 11:20 回复