phpcms常用标签

[复制链接]
zyfyyxs 发表于 2023-9-16 11:31:49|来自:北京 | 显示全部楼层 |阅读模式
顶级栏目名称:{$CATEGORYS[$top_parentid][catname]}
顶级栏目url:{$CATEGORYS[$top_parentid][url]}
顶级栏目id:{$CATEGORYS[$top_parentid][catid]}
其他字段只需要改动xxx:{$CATEGORYS[$top_parentid][xxx]}
父栏目名称:{$CATEGORYS[$CAT[parentid]][catname]}
父栏目url:{$CATEGORYS[$CAT[parentid]][url]}
父栏目id:{$CATEGORYS[$CAT[parentid]][catid]}
其他字段只需要改动xxx:{$CATEGORYS[$CAT[parentid]][xxx]}
**************************
内容页:
{$CAT[catid]}//调用上一级 栏目id
{$CAT[catname]}//调用上一级 栏目名称
{$CAT[url]}//调用上一级 栏目url
*****************************
{go($catid,$id)} 获取当前页面链接 {$url}在静态时不正常
{$CATEGORYS[$catid][url]} 显示当前栏目链接
{$CATEGORYS[$catid][catname]} 显示当前栏目名称
{$CATEGORYS[$r[catid]][catname]}循环内显示栏目
{if $r[thumb]}<img src=&#34;{thumb($r[thumb],120,90)}&#34;
alt=&#34;{$r[title]}&#34; width=&#34;120&#34; height=&#34;90&#34; />{/if}有图显示图 没图不显示
截取:{str_cut($r[title],46,'')}
{str_cut(strip_tags($r[content]),400)} 列表页调取内容 过滤html标签 需要加moreinfo=&#34;1&#34;
{date('Y-m-d H:i:s', $r['inputtime'])} 列表页调取发布时间
{date('Y-m-d',strtotime($inputtime))} 或者 {date('Y-m-d',time($inputtime))} 内容页调取发布时间
**********************************************************************
phpcms 调用当前栏目下的子栏目
category.html 写以下代码:
{loop subcat($catid) $r}
                 <ul>
                <li><a href=&#34;{$r[url]}&#34; title=&#34;{$r[catname]}&#34;>{$r[catname]}</a></li>
                </ul>
{/loop}
list.html 写以下代码:
  {loop subcat($catid) $r}
<ul>
<li><a href=&#34;{$CATEGORYS[$r[catid]][url]}&#34;>{$CATEGORYS[$r[catid]][catname]}</a></li>
</ul>
{/loop}
********************************************************************************
<div class=&#34;pindaoright&#34; {if $r[thumb]==&#34;&#34;} style=&#34;width:100%;&#34; {/if}>
如果图片不存在 则执行某某
********************************
{if $r['catid']==$catid} class=&#34;newclass&#34; {/if} 导航栏当前栏目增加class
*********************************************************
phpcms分页代码
<style type=&#34;text/css&#34;>
.text-c {margin:10px 0;}
.text-c a {padding:5px;margin:0 8px;border:1px solid #ccc;background-color:#eee;}
</style>       
<center><div id=&#34;pages&#34; class=&#34;text-c&#34;>{$pages}</div></center>
****************************************************************
phpcms v9列表页默认分页页码为10页,下面为分页页码条数的修改方法:

打开phpcms\libs\functions\global.func.php文件,
找到function pages函数(在672行左右)

修改下面代码中红色数字(10)为你想要显示的页码条数即可。

function pages($num, $curr_page, $perpage = 20, $urlrule = '', $array = array(),$setpages =?10)
---------------------
手机端图片自适应大小和居中 文章缩进
<style type=&#34;text/css&#34;>
        .part img {
            width:100%!important;
            height: auto!important;
            display: table-cell!important;   
        }
        .part p {
            text-indent: 2em;
        }
    </style>
-------------------------------------
第一个是图 剩下的是列表
{pc:content action=&#34;lists&#34; catid=&#34;7&#34; order=&#34;listorder DESC&#34; thumb=&#34;1&#34; num=&#34;1&#34;}
{php $imgarr=array();$count=0;}
{loop $data $r}
{php array_push($imgarr,$r[id]);}
<h4>
<a href=&#34;{$r[url]}&#34; target=&#34;_blank&#34; title=&#34;{$r[title]}&#34;>{str_cut($r[title],60,'')}</a>
</h4>
<a href=&#34;{$r[url]}&#34; target=&#34;_blank&#34; title=&#34;{$r[title]}&#34;>
<img src=&#34;{thumb($r[thumb],100,70)}&#34; width=&#34;100&#34; height=&#34;70&#34; alt=&#34;{$r[title]}&#34;>
</a>
                <p>{str_cut($r[description],90)}</p>
                {/loop}
                {/pc}
              </div>
              <ul>
                {pc:content action=&#34;lists&#34; catid=&#34;7&#34; order=&#34;listorder DESC&#34; num=&#34;5&#34;}
                {loop $data $r}
                {if $count<4&&!in_array($r[id],$imgarr)}
                {php $count++;}
                <li><a href=&#34;{$r[url]}&#34; target=&#34;_blank&#34; title=&#34;{$r[title]}&#34;>{str_cut($r[title],57,'')}</a></li>
                {/if}              
                {/loop}
                {/pc}
*********************************************
phpcms调用sql实例
{pc:get sql=&#34;select * from v9_news where catid=$catid and id!=$id order by updatetime desc&#34; num=&#34;10&#34;}
{loop $data $r}
<li>
<a target=&#34;_blank&#34; href=&#34;{$r[url]}&#34; style=&#34;color:#333333;&#34;>{$r[title]}</a>
<span style=&#34;margin-left: 30px;color: #666;font-size: 14px;&#34;>{date('Y-m-d', $r[updatetime])}</span>
</li>
{/loop}
{/pc}
{pc:get sql=&#34;SELECT * FROM `v9_news` WHERE thumb!='$thumb' Order by id DESC &#34; num=&#34;50&#34;} 调用有图片的最新新闻
        {loop $data $r}
织梦调用sql实例
{dede:sql sql=&#34;select * from dede_archives where typeid=5 and id!=~id~&#34;}
<li>
<a href=&#34;[field:id function=IDReturnURL(@me)/]&#34; class=&#34;step-link&#34;>[field:title/]</a>
</li>
{/dede:sql}
全部回复0 显示全部楼层
暂无回复,精彩从你开始!

快速回帖

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则