Home > CMS Tutorial > PHPCMS > Recommended PHPCMS guide

Recommended PHPCMS guide

coldplay.xixi
Release: 2020-12-22 17:28:10
forward
4271 people have browsed it

PHPCMS usage tutorialThe column introduces frequently used syntax

Recommended PHPCMS guide

Recommended (free) :PHPCMS usage tutorial

Comment call:

{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));}

comment: {if $comment_total}{$comment_total}{else}0{/if}
Copy after login

Recommended position call:

{pc:content action="position" posid="2"  moreinfo="1" catid="$catid" order="listorder DESC" num="1"}
{loop $data $r}
{/loop}
{/pc}
Copy after login

Click call:

<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
Copy after login

List page call:

{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{$views}
Copy after login

Content page call:

hit:<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
Copy after login

Total number of judgments:

{if $n==count($dat)}class="friendly-border" {/if}
Copy after login

News previous article next article display

<span class="fl">上一篇:<a href="{$previous_page[url]}">{$previous_page[title]}</a></span>
<span class="fr">下一篇:<a href="{$next_page[url]}">{$next_page[title]}</a></span>
Copy after login

Phpcms grouping

array_chunk($data(数组),10(每组有几个数))

<p class="bd">
    {pc:content action="lists" moreinfo="1" catid="17" num="20" order="id ASC"}
    {php $da=array_chunk($data,4(每组显示几个));}
        {loop $da $d}
        <p class="wrap1">
          {php $i=1;}
            {loop $d $r}
            <p class="box1 {if $i==4} br1 {/if}">
                <a class="hot" href="{$r[url]}" >
                ![]({$r[thumb]})
                <p>{$r[title]}</p>
                </a>
            </p>
            {php $i++;}
            {/loop}
        </p>
        {/loop}
        {/pc}
        
    </p>
Copy after login

//Intercept the number of words

{str_cut($r[description],102,'...')} 

{str_cut(strip_tags($r[content]),300,"...")}  //截取文字  strip_tags() 函数剥去字符串中的 HTML、XML 以及 PHP 的标签。
Copy after login

Add to favorites and set the homepage

<a target=_top href="javascript:window.external.addFavorite(&#39;http://www.webjx.com&#39;,&#39;网页教学网&#39;);">加入收藏</a>
<a  href=&#39;#&#39; onClick="this.style.behavior=&#39;url(#default#homepage)&#39;;this.setHomePage(&#39;http://www.webjx.com&#39;);">设为首页</a>
Copy after login

Add anchor

{$r[url]}#n{$r[id]}  {$rs[url]}&#area{$n}
Copy after login

Time difference

{php $now = strtotime("now")}
{date('d',$now-$r[inputtime])}天前
Copy after login

Get the current column

{php $arrid=$r[catid]}   {$CATEGORYS[$arrid][catname]}
Copy after login

Get the parent column of the current column

{$CATEGORYS[$CATEGORYS[$arrid][parentid]][catname]}
Copy after login

Current position call:

{catpos($catid)}
Copy after login

phpcms starts calling from the specified number

{pc:content action="lists" catid="10" order="id DESC LIMIT 1,4--" num="4"}
//这样就可以从第二条开始调用数据。



其中的order="id DESC LIMIT 1,4--"里的两个数字,第1个数字1表示从第2条开始调用,第2个数字4表示共调用4条。

如果改成order="id DESC LIMIT 0,4--"那么就表示从第1条开始调用,共调用4条。

如果改成order="id DESC LIMIT 2,4--"那么就表示从第3条开始调用,共调用4条。


栏目指定第几个显示(phpcms从指定第几条开始调用 )
1--->      从第二个开始显示
{php $data = array_slice($data,1);}


     {pc:content action="category" catid="$catid" num="5" siteid="$siteid" order="listorder ASC,id ASC"}
    {php $data = array_slice($data,1);}
        {loop $data $r}
             {if $cat==$catid}
            <span {if $n=="1"} class="cur" {/if} >{$r[catname]}</span>
             {else}
            <span {if $r[catid]==$catid} class="cur" {/if}>{$r[catname]}</span>                        {/if}
             {/loop}
        {/pc}
Copy after login

Return to the previous level

{$CATEGORYS[$catid][url]}
<a href="javascript:history.back(-1);" class="back">返回上一级</a>
Copy after login

Related articles

{pc:content action="relation" relation="$relation" catid="$catid" num="5" keywords="$rs[keywords]"}
{loop $data $r}
<li>·<a href="{$r[url]}" target="_blank">{$r[title]}</a><span>({date('Y-m-d',$r[inputtime])})</span></li>
{/loop}
{/pc}
Copy after login

Calling multiple pictures

{loop string2array($r['pics'])  $v}
Copy after login

Calling ads

{php $banner=getads(11);$i=1;}
    <ul>
        {loop $banner[d] $v}
        {if $i<=5}
       <li _src="url({$v[imageurl]})" style="background:none no-repeat center center;"><a href="{$v[linkurl]}"></a></li>
       {/if}
       {php $i++;}
       {/loop}  
       </ul>
Copy after login

Calling friendly links

图片链接:
{pc:link action="lists" typeid="0" siteid="$siteid" linktype="1" order="desc" num="6" return="dat"}
    {loop $dat $v}
     <a href="{$v[url]}" title="{$v[name]}" target="_blank">![]({$v[logo]})</a>
     {/loop}
{/pc}
文字链接:
{pc:link action="lists" typeid="0" siteid="$siteid" linktype="0" order="desc" num="10" return="dat"}
    {loop $dat $v}
             <a href="{$v[url]}" title="{$v[name]}"  target="_blank">{$v[name]} </a>
        {/loop}
{/pc}
Copy after login

Judge whether the array contains a certain number

if(in_array("29",$xmlx)){
    //array_push($xmlx,$qt);
    $qt=$_POST['qita'];
}
Copy after login

Column page calling source:

{php list($copyfrom) = explode('|', $r['copyfrom'])}  {$copyfrom}
Copy after login

Call verification code:

前台
{php pc_base::load_sys_class('form', '', 0);$setting = getcache('formguide', 'commons');} 
{form::checkcode('code_img', '4', 90, 30)}
 {form::checkcode('code_img','4','14',110,30)}
后台开始session配置
//启动session
$session_storage = 'session_'.pc_base::load_config('system','session_storage');
pc_base::load_sys_class($session_storage);
Copy after login

Mysql search how to determine whether a field contains a certain string

利用mysql 字符串函数 find_in_set();

SELECT * FROM users WHERE find_in_set('aa@email.com', emails);
Copy after login

Calling the model drop-down box

{php $ks=filtersele('dertment',12);}
Copy after login

Path jump (without a tag):

<script>
    function urls(obj){
    var url = $(obj).attr('data-url');
    window.location.href = url;
}
</script>
<span data-url="javascript:history.back();"  onclick="urls(this)"  >返回</span>
Copy after login

Jump to the home page

{siteurl($siteid)}
Copy after login

Column picture call

{$CATEGORYS[$catid][image]}
Copy after login

Mobile site previous articleNext article

PHP源码修改:
打开 phpcms\modules\wap\index.php 文件
找到
if(!$r || $r['status'] != 99) showmessage(L('info_does_not_exists'),'blank');
在其下面添加
//上一篇
$previous_page = $this->db->get_one("`catid` = '$catid' AND `id`<&#39;$id&#39; AND `status`=99",&#39;*&#39;,&#39;id DESC&#39;);
//下一篇
$next_page = $this->db->get_one("`catid`= '$catid' AND `id`>'$id' AND `status`=99");
//当前页为第一篇时:再点击上一篇仍然显示第一篇
if(empty($previous_page)) {
$previous_page = $this->db->get_one("`catid` = '$catid' AND `id`='$id' AND `status`=99",'*','id DESC');
}
//当前页为最后一篇时:再点击下一篇仍然显示最后一篇
if(empty($next_page)) {
$next_page = $this->db->get_one("`catid`= '$catid' AND `id`='$id' AND `status`=99");
}

调用:
 <a href="{WAP_SITEURL}?m=wap&c=index&a=show&catid={$catid}&typeid={$typeid}&id={$previous_page[id]}" class="page">上一条:{$previous_page[title]}</a>            
<a href="{WAP_SITEURL}?m=wap&c=index&a=show&catid={$catid}&typeid={$typeid}&id={$next_page[id]}" class="page">下一条: {$next_page[title]}</a>
Copy after login

Mobile site call Column picture

{$TYPE[$typeid][image]}
Copy after login

Column secondary display

{pc:content action="category" catid="0" order="listorder DESC" siteid="$siteid" num="7"}
        {loop $data $r}
            <li class="navList {if $r[catid]==$catid||$r[catid]==$cat}on{/if}" >
                <a href="{$r[url]}" class="href">{$r[catname]}</a>

                    <p class="listList">
                    {pc:content action="category" catid="$r[catid]" num="8" siteid="$siteid" order="listorder DESC" return="dat"}
                    {loop $dat $v}
                        <a href="{$v[url]}">{$v[catname]}</a>
                    {/loop}
                    {/pc}
                    </p>
            </li>
        {/loop}
        {/pc}
Copy after login

Download model

        {pc:content action="lists" catid="$catid" num="15" order="id DESC" page="$page" moreinfo="1"}
        {loop $data $r}
            {php $xiazai = string2array($r['downfiles']);}
            {loop $xiazai $b}
                <dl class="news_dl">
                    <dt>
                        <a href="{$b[fileurl]}"  title="{$r[title]}" class="dt_1">
                            {$r[title]}
                        </a>
                        <span class="dt_2">[{date('Y-m H:i',$r[inputtime])}]</span>
                    </dt>
                    <dd>
                        {str_cut(strip_tags($r[content]),340)}
                    </dd>
                </dl>
                <!-- 文件地址调用标签:{$b[fileurl]}     文件名调用标签:{$b[filename]} -->
            {/loop}
        {/loop}
        {/pc}
Copy after login

Judge odd and even numbers

{$n}.{if $n%2==0}偶数{else}奇数{/if}   <br>
Copy after login

The above is the detailed content of Recommended PHPCMS guide. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jianshu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template