如何用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表單功能 提交之后如何返回當前頁面,而不是默認的首頁文件地址找到 phpcms\modules\formguide\index.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.縮略圖以及圖集無法上傳\phpcms\libs\classes\attachment.class.php請把24行的(也有可能是 23行)$this->upload_func = 'copy';改成$this->upload_func = 'move_uploaded_file';2.碎片模塊搜索文章看不到欄目phpcms\modules\block\templates \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}
復制代碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM