国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > CMS > PhpCMS > 正文

phpcms v9筆記之模板制作案例

2024-09-10 07:16:02
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

調(diào)用最新文章:帶所在版塊

  1. {pc:get sql="SELECT a.title, a.catid, b.catid, b.catname, a.url as turl ,b.url as curl,   
  2.    
  3. a.id FROM `v9_news` a, `v9_category` b WHERE a.catid = b.catid ORDER BY `a`.`id` DESC "   
  4.    
  5. num="15" cache="300"}   
  6. {loop $data $r}   
  7. <h6>   
  8.     <font class="cate">   
  9.         <a href="http://xzl52199.blog.163.com/blog/{$r[curl]}">[{$r[catname]}]</a>   
  10.     </font>   
  11.     <a href="http://xzl52199.blog.163.com/blog/{$r[turl]}" title="{$r[title]}">{str_cut($r['title'],26)}</a>   
  12. </h6>   
  13. {/loop}   
  14. {/pc}   
  15.    
  16. ====<font class="cate"><a href="http://xzl52199.blog.163.com/blog/{$r[curl]}">[{$r[catname]}]</a></font>所在版塊的調(diào)用  

截取調(diào)用標(biāo)題長(zhǎng)度:

  1. {str_cut($v[title],36,'')}   
  2.    
  3. {str_cut($v['title'],34)} 超出用 ... 代替   
  4.    
  5. {str_cut($v['title'],34, '???')}超出用 ???代替   
  6.    
  7. {str_cut($v['title'],34,'')}超出不用任何字符代替  

格式化時(shí)間

  1. 調(diào)用格式化時(shí)間 2011-05-06 11:22:33   
  2.    
  3. {date('Y-m-d H:i:s',$r[inputtime])}   
  4.    
  5. <span class="rt">{date('m-d',$v['inputtime'])}</span> 

多欄目調(diào)用&多推薦位調(diào)用

調(diào)用需求:文章范圍為59 60 61三個(gè)欄目,并且推送到了27 和28兩個(gè)推薦位;從第三條開(kāi)始,連續(xù)調(diào)用7篇文章.

  1. {pc:get sql="SELECT * FROM v9_news WHERE id IN (SELECT id FROM v9_position_data WHERE posid   
  2.    
  3. in(27,28) and catid in(59,60,61)) order by listorder DESC" cache="3600" start="3" num="7"   
  4.    
  5. return="data" }   
  6. {loop $data $n $r}   
  7. <li>·<a target="_blank" href='http://xzl52199.blog.163.com/blog/{$r[url]}' title="{$r[title]}" style="color:Black;">{str_cut   
  8.    
  9. ($r[title],22,'')}</a></li>   
  10. {/loop}   
  11. {/pc} 

顯示欄目名稱(chēng)(只是名稱(chēng),不帶鏈接)

{$catname}  

顯示欄目名稱(chēng)和鏈接(可以點(diǎn)擊)  

<a href="http://xzl52199.blog.163.com/blog/{$CATEGORYS[$r[catid]][url]}">{$CATEGORYS[$r['catid']]['catname']}</A>  

獲取父欄目id/獲取父欄目名稱(chēng):

{$CATEGORY[$catid][parentid]}  

父欄目名稱(chēng):{$CATEGORYS[$CAT[parentid]][catname]}  

外部數(shù)據(jù)源調(diào)用:dedecmsdb 在后臺(tái)數(shù)據(jù)源處添加:

  1. {pc:get sql="SELECT * FROM cq_member where mtype='企業(yè)' " cache="3600" dbsource="dedecmsdb"   
  2.    
  3. num="7" return="data"}   
  4.    
  5. {loop $data $r}   
  6.    
  7. <a href="/member/index.php?uid={$r[userid]}" title="{$r[uname]}" target="_blank">  //開(kāi)源軟件:Vevb.com 
  8. {str_cut($r[uname],28,'')}</a>   
  9.    
  10. {/loop}   
  11.    
  12. {/pc} 

調(diào)用子欄目(在欄目首頁(yè)模板需要用到):

  1. {pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorderASC"}   
  2. {loop $data $r}   
  3. <a href="http://xzl52199.blog.163.com/blog/{$r[url]}">{$r[catname]}</a> |   
  4. {/loop}   
  5. {/pc} 

顯示指定id的欄目名稱(chēng),例子這里catid=22.

{$CATEGORYS[22]['catname']}  

在文章面前顯示文章類(lèi)別:

  1. {pc:content action="lists" catid="79" order="listorder DESC" num="14" }   
  2. <?php $TYPE = getcache('type_content','commons');?>   
  3. {loop $data $n $r}   
  4. <li>{if $TYPE[$r[typeid]][name]}<span style="color:#CC6600">[ {$TYPE[$r[typeid]][name]}]   
  5.    
  6. </span>{/if}<a href="http://xzl52199.blog.163.com/blog/{$r['url']}"{title_style($r[style])}title="{$r['title']}"   
  7.    
  8. target="_blank">{str_cut($r[title],33,'')}</a></li>   
  9. {/loop}   
  10.    
  11. {/pc} 

指定變量循環(huán)增長(zhǎng)(幻燈片經(jīng)常用到):

  1. [php] view plaincopyprint? 
  2. {pc:content action="lists" catid="66" order="listorder DESC" thumb="1" num="5" }   
  3.    
  4. {php $num = 0}   
  5.    
  6. {loop $data $r}   
  7.    
  8. linkarr[{$num}] = "{$r[url]}";   
  9. picarr[{$num}] = "{$r[thumb]}";   
  10. textarr[{$num}] = "{str_cut($r[title],36,'')}";   
  11. {php $num++}   
  12.    
  13. {/loop}   
  14.    
  15. {/pc} 

文章調(diào)用使用limit:

  1. {pc:content action="position" posid="36" num="1" order="listorder DESC limit 1,1--" }   
  2. //其他都是跟以前一樣使用   
  3. {pc:content action="position" posid="31" order="listorder DESC" limit='1,8--'}   
  4. {loop $data $r}   
  5. <li><a href="http://blog.csdn.net/lee_magnum/{$r[url]}" title="{$r[title]}" target=_blank>{str_cut($r[title],36,'')}   
  6.    
  7. </a></li>   
  8. {/loop}   
  9. {/pc} 

文章從指定位置開(kāi)始調(diào)用,起始位置為5,調(diào)用3條,相當(dāng)于limit功能:

  1. {pc:content action="position" posid="27" order="listorder DESC" num="3" start="5"}   
  2. {loop $data $r}   
  3. <a href='http://xzl52199.blog.163.com/blog/{$r[url]}'>{str_cut($r[description],115)}... </a>   
  4. {/loop}   
  5. {/pc} 

文章列表頁(yè)調(diào)用關(guān)鍵字,或者首頁(yè)調(diào)用關(guān)鍵字.

注意:explode(',',$r[keywords]);是將文章關(guān)鍵詞通過(guò)英文逗號(hào)分離,也就是說(shuō)每一篇文章都要以逗號(hào)間隔關(guān)鍵字,否則調(diào)用出來(lái)會(huì) 是全部作為一個(gè)關(guān)鍵字,如果是空格間隔關(guān)鍵字,將explode(',',$r[keywords]);改成explode(' ',$r[keywords]);:

  1. {pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"}   
  2. {loop $data $r}   
  3. <a href="http://xzl52199.blog.163.com/blog/{$r[url]}">{$r[title]}</a>   
  4. {php $keywords = explode(',',$r[keywords]);}   
  5. <b>文章標(biāo)簽:</b>   
  6. {loop $keywords $keyword}   
  7. <a href="http://xzl52199.blog.163.com/blog/{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}"   
  8.    
  9. class="blue"> {$keyword}</a>   
  10. {/loop}   
  11. {/loop}   
  12. {/pc}   

每當(dāng)列表幾行的時(shí)候出現(xiàn)一次某些符號(hào),比如首頁(yè)里面的文章推薦,一行顯示兩條,在這兩條中間想加一條豎線 | 就用到這個(gè)代碼了,數(shù)量大的話就容易出錯(cuò),因?yàn)槟_\(yùn)算嘛~~呵呵 不過(guò)一般也就4個(gè)標(biāo)題以下:

  1. {pc:content action="position" posid="8" order="listorder DESC" num="2"}   
  2. {loop $data $r}   
  3. <a style="color:#040605" title="{$r[title]}" href="http://xzl52199.blog.163.com/blog/{$r[url]}" target=_blank>{str_cut($r   
  4.    
  5. [title],26,'')}</a>{if $n%2==1} |{/if}   
  6. {/loop}   
  7. {/pc} 

v9 列表頁(yè)完美支持自定義段調(diào)用:

  1. {pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}   
  2. {loop $data $r}   
  3. <a href="http://blog.csdn.net/lee_magnum/{$r[url]}">[{$r['字段名']}]> {$r[title]}</a>   
  4. {/loop}   
  5. <div class="pagebar">{$pages}</div>   
  6. {/pc} 

當(dāng)前欄目調(diào)用父級(jí)及以下欄目信息方法,其他代碼,該咋地還是要咋地,這是要素:

  1. {php $arrchildid = $CATEGORYS[$CAT[parentid]][arrchildid]}   
  2. {pc:get sql="SELECT * FROM v9_news where catid in($arrchildid) cache="3600" page="$page" num="12" return="data"} 

V9表單功能,提交之后如何返回當(dāng)前頁(yè)面,而不是默認(rèn)的首頁(yè)文件地址,找到 phpcms/modules/formguide/index.php文件第73行:

showmessage(L('thanks'), APP_PATH);  

修改成,如下代碼即可實(shí)現(xiàn)自動(dòng)返回前一頁(yè):

showmessage(L('thanks'), HTTP_REFERER);

v9 首頁(yè)或分頁(yè)自定義字段調(diào)用,普通列表或欄目調(diào)用自定義字段,在{pc:content action="lists" 后加上副表moreinfo=1 (等于1時(shí)顯示,0時(shí)不顯示),例子:

  1. {pc:content action="lists" moreinfo=1 catid="2" order="id DESC" num="4"}   
  2. <ul>   
  3. {loop $data $key $val}   
  4. <li><a href="http://xzl52199.blog.163.com/blog/{$val['url']}">{$val['title']}</a>   
  5. <br>價(jià)格:{str_cut($v['自定義段'],100)} //100 是字?jǐn)?shù)   
  6. </li>   
  7. {/loop}   
  8. </ul>   
  9. {/pc} 

推薦位調(diào)用自定義字段:

在模型里加好自定義字段后,必須把“在推薦位標(biāo)簽中調(diào)用”點(diǎn)擊“是“,然后用同一樣的方法去調(diào)節(jié)數(shù)據(jù)就OK了,記住,如果你加了文章,必須去更新文章才會(huì)顯示,自定義段在推薦中只顯示你選擇后,選擇前加的加文章不顯示,更新一下文章就顯示了.

例子:

  1. {pc:content action="position" posid="推薦位id" num="30" thumb="1" moreinfo="1" order="listorder DESC"}   
  2. {loop $data $key $val}   
  3. <li>   
  4.     <a href="http://xzl52199.blog.163.com/blog/{$val['url']}" target="_blank">   
  5.         <img src="http://xzl52199.blog.163.com/blog/{$val['自定義段']}" alt="{$val['title']}" height=36 width=98 />   
  6.     </a>  //開(kāi)源軟件:Vevb.com 
  7.     <a href="http://xzl52199.blog.163.com/blog/{$val['url']}" target="_blank">{str_cut($val['title'],20)}</a>   
  8. </li>   
  9. {/loop}   
  10. {/pc} 

編輯器上傳圖片自動(dòng)使用標(biāo)題作為alt參數(shù).

一:修改 statics/js/ckeditor/plugins/image/dialogs/image.js

找到 accessKey:'T','default':'' 替換成:accessKey:'T','default':$('#title').val()

二:清除瀏覽器緩存

增加文章的隨機(jī)點(diǎn)擊數(shù),找到100行的:

$views = $r['views'] +1

修改為:

$rand_nums=rand(79,186);$views = $r['views'] + $rand_nums;  

表示點(diǎn)擊一次,增加79到186次不等,tips:某些版本出錯(cuò)民間解決方法.

1.縮略圖以及圖集無(wú)法上傳

/phpcms/libs/classes/attachment.class.php  

請(qǐng)把24行的(也有可能是23行)

$this->upload_func = 'copy';

改成

$this->upload_func = 'move_uploaded_file';

2.碎片模塊搜索文章看不到欄目

phpcms/modules/block/templates/search_content.tpl.php 13行改成:

  1. <td><?php   
  2. if(isset($_GET['dosubmit'])){?><div class="rt"><a   
  3. href="javascript:void(0)" onclick="$('#search').toggle()"><?php   
  4. echo L('folded_up_in_search_of')?></a></div><?php }   
  5. echo form::select_category(''$catid'name="catid" id="catid"''',   
  6. '''0', 1)?> </td>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡东县| 徐州市| 乡宁县| 嘉善县| 沭阳县| 会宁县| 两当县| 邢台县| 弋阳县| 新河县| 平果县| 宜君县| 巴里| 株洲市| 沭阳县| 新晃| 南雄市| 康定县| 临湘市| 和田县| 洪湖市| 宁远县| 普陀区| 黑水县| 绥化市| 沁阳市| 绥德县| 监利县| 望江县| 山东省| 奇台县| 山西省| 永济市| 望都县| 五寨县| 理塘县| 临洮县| 巴彦淖尔市| 横峰县| 绥芬河市| 田林县|