zoukankan      html  css  js  c++  java
  • 如何用PC标签在列表页中调出文章内容 phpcms

    如何用PC标签在列表页中调出文章内容

    phpcms v9 moreinfo=”"参数说明

    {pc:content action="lists" catid="$catid" num="15" order="id DESC" page="$page"moreinfo="1" }

    参数名是否必须默认值说明:
    catid否null调用栏目ID
    thumb否0是否仅必须缩略图
    order否null排序类型
    num是null数据调用数量
    moreinfo否0是否调用副表数据。

    举个例子
    对于文章储层而言,有v9_news和v9_news_data两个表,前面就是主表,后面是副表。如果需要调用文章内容,则这个字段是在v9_news_data 的content字段,在列表页是不能直接调用的,
    然后添加 moreinfo="1"等于是结合两个表的字段,这样{$r['content']}就可以在pc:content action="lists"调用出数据了。
    {pc:content action="lists" moreinfo="1" catid="$catid" num="25" order="id DESC" page="$page"}
    {loop $data $r}
    <div class="w680" id="{$n}">
    <div {if $n%2==1}class="bj_06"{/if}{if $n%2==0}class="bj_07"{/if}>

    <img src="{$r[thumb]}" />
    <br />
    {$r[content]}

    </div>
    </div>
    {/loop}
    {$pages}
    {/pc}

    moreinfo="1"

    在标签中加上
    moreinfo="1" 为0不调用副表
    官方是这样描述的
    提醒:从PHPCMS
    V9 Beta
    20101105 版本开始支持moreinfo参数属性,本参数表示在返回数据的时候,会把副表中的数据也一起返回。一个内容模型分为2个表,一个主表一个副表,主表中一 般是保存了标题、所属栏目等等短小的数据(方便用于索引),而副表则保存了大字段的数据,如内容等数据。在模型管理中新建字段的时候,是允许你选择存入到 主表还是副表的(我们推荐的是,把不重要的信息放到副表中)。想要在列表中调取副表的数据就需要在PC标签中使用moreinfo这个属性。

    //待修改

    总结phpcms v9最常用的23个调用代码:

      调用最新文章,带所在版块{pc:get sql="SELECT a.title, a.catid, b.catid, b.catname, a.url as turl ,b.url as curl,a.id FROM `v9_news` a, `v9_category` b WHERE a.catid = b.catid ORDER BY `a`.`id` DESC "num="15" cache="300"}

    {loop $data $r}

    <h6><font class="cate"><a href="{$r[curl]}">[{$r[catname]}]</a></font><aclass="gray" href="{$r[turl]}" title="{$r[title]}"> {str_cut($r['title'],26)}</a></h6>

    {/loop}

    {/pc}

    ====<font class="cate"><a href="{$r[curl]}">[{$r[catname]}]</a></font>所在版块的调用1.截取调用标题长度{str_cut($v[title],36,'')}

    {str_cut($v['title'],34)} 超出用 ... 代替{str_cut($v['title'],34, '???')}超出用 ???代替{str_cut($v['title'],34,'')}超出不用任何字符代替2.格式化时间调用格式化时间 2011-05-06 11:22:33{date('Y-m-d H:i:s',$r[inputtime])}

    <span class="rt">{date('m-d',$v['inputtime'])}</span>

    {pc:get sql="SELECT * FROM v9_news WHERE id IN (SELECT id FROM v9_position_data WHERE posidin(27,28) and catid in(59,60,61)) order by listorder DESC" cache="3600" start="3" num="7"return="data" }

    {loop $data $n $r}

    <li>·<a target="_blank" href='{$r[ur l]}' title="{$r[title]}" style="color:Black;">{str_cut($r[title],22,'')}</a></li>

    {/loop}

    {/pc}

      4.显示栏目名称(只是名称,不带链接){$catname}

    显示栏目名称和链接(可以点击)<a href="{$CATEGORYS[$r[catid]]}">{$CATEGORYS[$r['catid']]['catname']}</A>

      5.获取父栏目id/获取父栏目名称{$CATEGORY[$catid][parentid]}

      父栏目名称:{$CATEGORYS[$CAT[parentid]][catname]}

      6.外部数据源调用dedecmsdb 在后台数据源处添加{pc:get sql="SELECT * FROM cq_member where mtype='企业' " cache="3600" dbsource="dedecmsdb"num="7" return="data"}

      {loop $data $r}

      <a href="/member/index.php?uid={$r[userid]}" title="{$r[uname]}" target="_blank">{str_cut($r[uname],28,'')}</a>

      {/loop}

      {/pc}

      7.调用子栏目(在栏目首页模板需要用到){pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorderASC"}

      {loop $data $r}

      <a href="{$r[url]}">{$r[catname]}</a> |{/loop}

      {/pc}

      8.显示指定id的栏目名称 (例子这里catid=22){$CATEGORYS[22]['catname']}

      9.在文章面前显示文章类别{pc:content action="lists" catid="79" order="listorder DESC" num="14" }

      <?php $TYPE = getcache('type_content','commons');?>

      {loop $data $n $r}

      <li>{if $TYPE[$r[typeid]][name]}<span style="color:#CC6600">[ {$TYPE[$r[typeid]][name]}]

      </span>{/if}<a href="{$r['url']}"{title_style($r[style])}title="{$r['title']}"target="_blank">{str_cut($r[title],33,'')}</a></li>

      {/loop}

      {/pc}

      10.指定变量循环增长(幻灯片经常用到){pc:content action="lists" catid="66" order="listorder DESC" thumb="1" num="5" }

      {php $num = 0}

      {loop $data $r}

      linkarr[{$num}] = "{$r[url]}";picarr[{$num}] = "{$r[thumb]}";textarr[{$num}] = "{str_cut($r[title],36,'')}";{php $num++}

      {/loop}

      {/pc}

      11.文章调用使用limit{pc:content action="position" posid="36" num="1" order="listorder DESC limit 1,1--" }

      其他都是跟以前一样使用{pc:content action="position" posid="31" order="listorder DESC" limit='1,8--'}

      {loop $data $r}

      <li><a href="{$r[url]}" title="{$r[title]}" target=_blank>{str_cut($r[title],36,'')}

      </a></li>

      {/loop}

      {/pc}

      12.文章从指定位置开始调用起始位置为5,调用3条。相当于limit功能。

      {pc:content action="position" posid="27" order="listorder DESC" num="3" start="5"}

      {loop $data $r}

      <a href='{$r[url]}'>{str_cut($r[description],115)}... </a>

      {/loop}

      {/pc}

    [page]

    13.文章列表页调用关键字,或者首页调用关键字注意:explode(',',$r[keywords]);是将文章关键词通过英文逗号分离,也就是说每一篇文章都要以逗号间隔关键字,否则调用出来会 是全部作为一个关键字。如果是空格间隔关键字,将explode(',',$r[keywords]);改成explode(' ',$r[keywords]);{pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"}

      {loop $data $r}

      <a href="{$r[url]}">{$r[title]}</a>

      {php $keywords = explode(',',$r[keywords]);}

      <b>文章标签:</b>

      {loop $keywords $keyword}

      <a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}"class="blue"> {$keyword}</a>

      {/loop}

      {/loop}

      {/pc}

      14.每当列表几行的时候出现一次某些符号(比如首页里面的文章推荐,一行显示两条,在这两条中间想加一条竖线 | 就用到这个代码了)数量大的话就容易出错,因为模运算嘛~~呵呵 不过一般也就4个标题以下{pc:content action="position" posid="8" order="listorder DESC" num="2"}

      {loop $data $r}

      <a style="color:#040605" title="{$r[title]}" href="{$r[url]}" target=_blank>{str_cut($r[title],26,'')}</a>{if $n%2==1} |{/if}

      {/loop}

      {/pc}

      15.v9 列表页完美支持自定义段调用{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page"moreinfo="1"}

      {loop $data $r}

      <a href="{$r[url]}">[{$r['字段名']}]> {$r[title]}</a>

      {/loop}

      <div class="pagebar">{$pages}</div>

      {/pc}

    [page]

    16.当前栏目调用父级及以下栏目信息方法其他代码 该咋地还是要咋地 。这是要素{php $arrchildid = $CATEGORYS[$CAT[parentid]][arrchildid]}

      {pc:get sql="SELECT * FROM v9_news where catid in($arrchildid) cache="3600" page="$page"num="12" return="data"}

      17.V9表单功能 提交之后如何返回当前页面,而不是默认的首页文件地址找到 phpcmsmodulesformguideindex.php文件第73行showmessage(L('thanks'), APP_PATH);修改成 如下代码即可实现自动返回前一页showmessage(L('thanks'), HTTP_REFERER);18.v9 首页或分页自定义字段调用和15差不多第一普通列表或栏目调用自定义字段在{pc:content action="lists" 后加上副表moreinfo=1 (等于1时显示,0时不显示)例子:

      {pc:content action="lists" moreinfo=1 catid="2" order="id DESC" num="4"}

      <ul>

      {loop $data $key $val}

      <li><a href="{$val['url']}">{$val['title']}</a>

      <br>价格:{str_cut($v['自定义段'],100)} //100 是字数</li>

      {/loop}

      </ul>

      {/pc}

      第二种推荐位调用自定义字段在模型里加好自定义字段后,必须把“在推荐位标签中调用”点击“是“然后用同一样的方法去调节数据就OK了,记住,如果你加了文章,必须去更新文章才会显示,自定义段在推荐中只显示你选择后,选择前加的加文章不显示,更新一下文章就显示了例子:

      {pc:content action="position" posid="推荐位id" num="30" thumb="1" moreinfo="1"order="listorder DESC"}

      {loop $data $key $val}

      <LI><a href="{$val['url']}" target="_blank"><img src="{$val['自定义段']}" alt="{$val['title']}" height=36 width=98 /></a>

      <a href="{$val['url']}" target="_blank">{str_cut($val['title'],20)}</a></LI>

      {/loop}

      {/pc}

      20.编辑器上传图片自动使用标题作为alt参数一: 修改 statics/js/ckeditor/plugins/image/dialogs/image.js找到accessKey:'T','default':''

      替换成accessKey:'T','default'('#title').val()二: 清除浏览器缓存21.增加文章的随机点击数找到100行的$views = $r['views'] +1修改为:

      $rand_nums=rand(79,186);$views = $r['views'] + $rand_nums;表示点击一次,增加79到186次不等 -------------------------------------------------------------tips:某些版本出错民间解决方法1.缩略图以及图集无法上传phpcmslibsclassesattachment.class.php请把24行的(也有可能是 23行)$this->upload_func = 'copy';改成$this->upload_func = 'move_uploaded_file';2.碎片模块搜索文章看不到栏目phpcmsmoduleslock emplates search_content.tpl.php13行改成<td><?phpif(isset($_GET['dosubmit'])){?><div class="rt"><ahref="javascript:void(0)" onclick="$('#search').toggle()"><?phpecho L('folded_up_in_search_of')?></a></div><?php }

      echo form::select_category('', $catid, 'name="catid" id="catid"', '','', '0', 1)?> </td>

      22、PHPCMS V9的get标签调用1、调用本系统单条数据,示例(调用ID为1的信息,标题长度不超过25个汉字,显示更新日期):

      {get sql="select * from phpcms_content where contentid=1" /}

      标题:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}

      2、调用本系统多条数据,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期):

      {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc"rows="10"}

      标题:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}

      {/get}

      3、带分页,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期,带分页):

      {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc"rows="10" page="$page"}

      标题:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}

      {/get}分页:{$pages} </div>

    PHPCMS V9标签详述-内容页部分,获取上上级栏目

    一、内容页部分标签调用,即show_x.html
    1、页面标题:{$title}
    2、发表时间:{$inputtime}
    3、内容来源:{$copyfrom}
    4、文章内容:{$content}
    5、缩略图地址:{$thumb}
    6、组图列表:
    {loop $photos $r} 
    <li><a href="{$r[url]}"><img src="{thumb($r[url], 75, 45, 0)}" alt="{$r[alt]}" /></a></li>
    {/loop}
    注释:其中$photos为自定义组图字段,{$r[url]}为图片地址,{thumb($r[url], 75, 45, 0)}为图片缩略图,{$r[alt]}为图片描述
    7、栏目名称与栏目拼音与栏目链接:{$CAT[catname]}  与  {$CAT[letter]}  与  {$CAT[url]}
    8、同级栏目列表:
    {pc:content action="category" catid="$parentid" num="12" siteid="$siteid" order="listorder ASC"}
          {loop $data $r}
                <li><a href="{$r[url]}">{$r[catname]}</a></li>
           {/loop}
    {/pc}
    9、父栏目名称与链接:{$CATEGORYS[$CAT[parentid]][catname]}  与  {$CATEGORYS[$CAT[parentid]][url]}
    10、一级父栏目列表:
    {pc:content action="category" catid="0" num="34" siteid="$siteid" order="listorder ASC"}
          {loop $data $r}
                <li><a href="{$r[url]}">{$r[catname]}</a></li>
          {/loop}
    {/pc}
    11、获取上上级栏目名称与链接:{$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][catname]} 与 {$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][url]}

    栏目结构是这样的   我想在产品中心页category显示栏目id   10~15的列表  如何做呢?
     
     
    栏目结构是这样的   我想在产品中心页category显示栏目id   10~15的列表  如何做呢?

    产品中心        内部栏目        产品模型                
            10              ├─ 智能停车系统        
            11              ├─ 立体停车场系统        
            12              ├─ 通道闸系统        
            13              ├─ 门禁、安防等系统        
            14              ├─ 各种门类        
            15              └─ 交通设施

    用这个语句就可以
    1. {pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorder ASC"}
    2. <ul>
    3. {loop $data $r}
    4. <li><a href="{$r[url]}">{$r[catname]}</a></li>
    5. {/loop}
    6. </ul>
    7. {/pc}
    复制代码


    产品中心        内部栏目        产品模型                
            10              ├─ 智能停车系统        
            11              ├─ 立体停车场系统        
            12              ├─ 通道闸系统        
            13              ├─ 门禁、安防等系统        
            14              ├─ 各种门类        
            15              └─ 交通设施

    用这个语句就可以
    1. {pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorder ASC"}
    2. <ul>
    3. {loop $data $r}
    4. <li><a href="{$r[url]}">{$r[catname]}</a></li>
    5. {/loop}
    6. </ul>
    7. {/pc}
    复制代码
  • 相关阅读:
    android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3
    display:inline-block的运用
    图解单片机8位PWM、16位PWM中“位”的含义!
    UVA10006
    [置顶] CF 86D Powerful array 分块算法入门,n*sqrt(n)
    俗人解释 三维渲染 在工作过程
    HDU 4414 Finding crosses(dfs)
    Codeforces 35E Parade 扫描线 + list
    hdu 4374 单调队列
    LeetCode OJ平台Sort Colors讨论主题算法
  • 原文地址:https://www.cnblogs.com/bjxing/p/3597385.html
Copyright © 2011-2022 走看看