phpcms標簽模板及專題模板的制作
2024-07-09 22:52:45
供稿:網友
phpcms標簽模板及專題模板的制作
1.標簽模板的制作
前面我們已經講到了每個頻道模板的制作,但是我們只是插入對應的標簽代碼,如何做到顯示的效果能個性化,滿足自己的要求呢?,那么我們就要對自己的標簽模板做個性化的設計
所有以tag_開頭的模板
都是標簽模板
以文章頻道的模板為例
我們會看到
tag_articlelist.html 文章列表標簽模板
tag_picarticle.html 圖片文章標簽模板
剩下的兩個我們一般做模板的時候,如果自己對于js代碼不是很理解的話,我們一般不會去動它,
打開文章列表標簽模板
CODE: [Copy to clipboard] <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
{loop $articles $i $article}
{if $i%$cols==0} <tr> {/if}
<td height="20" width="{$width}">
{$article[img]} {if $showcatname}{$article[catname]}{/if} <a href="{$article[url]}" title="{$article[alt]}" target="{$target}" class="tag_title_link">{$article[title]}</a>
{if $showhits}({$article[hits]}){/if}
{if $showauthor}[作者:{$article[author]}]{/if}
{if $article[showcommentlink]} <a href="{PHPCMS_PATH}comment/?item=articleid&itemid={$article[articleid]}" target="_blank"><span class="color_red">評</span></a>{/if}
{if $datetype}[<span class="tag_date">{$article[adddate]}</span>]{/if}
{if $descriptionlen}<br/><span class="tag_description"> {$article[description]}</span>{/if}
</td>
{if $i%$cols==($cols-1)}</tr>{/if}
{/loop}
</table>
{if $pages}
<div class="pages">{$pages}</div>
{/if} 這個里面
{loop $articles $i $article}是一個循環,我們要關注的就是這個循環里面的內容
{if $i%$cols==0} <tr> {/if} 我們在標簽里面設定的參數,顯示幾列,根據這個來控制標簽的顯示
{$article[img]} 文章的圖片,顯示精華,置頂,還是普通文章
{if $showcatname}{$article[catname]}{/if} 所屬欄目
{$article[url]} 文章路徑
{$article[title]} 文章標題
{if $showhits}({$article[hits]}){/if} 點擊數
{if $showauthor}[作者:{$article[author]}]{/if} 作者
{if $article[showcommentlink]} <a href="{PHPCMS_PATH}comment/?item=articleid&itemid={$article[articleid]}" target="_blank"><span class="color_red">評</span></a>{/if} 評論連接
{if $datetype}[<span class="tag_date">{$article[adddate]}</span>]{/if} 添加時間
{if $descriptionlen}<br/><span class="tag_description"> {$article[description]}</span>{/if} 描述說明
如果我們要實現時間的靠右對齊,那么我們可以把這個模板改成
CODE: [Copy to clipboard] <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
{loop $articles $i $article}
{if $i%$cols==0} <tr> {/if}
<td height="20" width="{$width}">
{$article[img]} {if $showcatname}{$article[catname]}{/if} <a href="{$article[url]}" title="{$article[alt]}" target="{$target}" class="tag_title_link">{$article[title]}</a>
{if $showhits}({$article[hits]}){/if}
{if $showauthor}[作者:{$article[author]}]{/if}
{if $article[showcommentlink]} <a href="{PHPCMS_PATH}comment/?item=articleid&itemid={$article[articleid]}" target="_blank"><span class="color_red">評</span></a>{/if}
{if $descriptionlen}<br/><span class="tag_description"> {$article[description]}</span>{/if}
</td>
<td>{if $datetype}[<span class="tag_date">{$article[adddate]}</span>]{/if}</td>
{if $i%$cols==($cols-1)}</tr>{/if}
{/loop}
</table>
{if $pages}
<div class="pages">{$pages}</div>
{/if} 或者設置css里面tag_date的屬性為float:right
圖片文章頁面的標簽模板也是如此,我們需要做的,基本上就是css的變化來控制效果,這就需要大家對于css有一個比較淺顯的掌握,具體可以參考css手冊,網上到處都是,指的說明的一點,css的簡寫僅僅支持IE,FF和opera尚不能全部支持!
2.專題模板的制作
專題頁面的制作主要設計的頁面有
special.html 專題首頁
special_list.html 專題列表頁
special_show.html專題內容頁
tag_speciallist.html專題標簽頁
專題是相同類型的文章組成的一個合集,大家可以把他看做一個欄目,只不過這個欄目比較特殊,它屬于一個頻道多個欄目下相同主題的文章合集,他的模板制作和文章欄目頁面的制作是一模一樣的,只不過是概念你的不同罷了,大家不要被這個概念嚇到了!
寫到這里,菠蘿教你做模板系列基本要完工了,剩下的模板中,官方在默認模板中都有了相應的提示文件,相信不是很難看懂
這個教程希望對大家做模板有一個啟發,請大家牢牢記住這一點
phpcms的模板就是html代碼+js+標簽
只要大家靈活掌握標簽的調用,那么一定會做出很多個性化的pp模板的!