歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 19, 2024, 08:01:08 上午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  模版設計  |  該如何在顯示文章列表? « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 該如何在顯示文章列表?  (閱讀 22400 次)
blue955
新手見習
*
文章: 4



檢視個人資料 個人網站
« 於: 八月 23, 2006, 09:56:29 上午 »

想要做的是,點選文章分類後,顯示該分類下的文章列表,例如:http://phys.idv.tw/plog/category/1/1

這樣感覺版面會比較整齊,有爬過文,可是還是感覺很模糊,應該修改哪各地方呢?

希望各位先進給我點幫助,謝謝!
已記錄
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #1 於: 八月 23, 2006, 11:31:54 上午 »

搜尋論壇,關鍵字:「 $showAll 」

lss
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
ted
一般會員
***
文章: 103


檢視個人資料
« 回覆文章 #2 於: 十一月 09, 2006, 07:54:21 上午 »

我今天從 1.0.6 升級到 1.1 之後, 原有文章分類的顯示方式也都改變了
原本是文章列表的, 但現在則連內文都出現了

找「 $showAll 」也沒看到相關的文章,有人可以指點一下嗎?


謝謝
已記錄

OS: windows server 2003
Apache Web Server Version 2.2.2
PHP Script Language Version 5.1.4
MySQL Database Version 5.0.22
hsuzy
新手見習
*
文章: 41


檢視個人資料
« 回覆文章 #3 於: 十一月 09, 2006, 01:51:30 下午 »

我今天從 1.0.6 升級到 1.1 之後, 原有文章分類的顯示方式也都改變了
原本是文章列表的, 但現在則連內文都出現了
找「 $showAll 」也沒看到相關的文章,有人可以指點一下嗎?
謝謝
參考一下 1.1版 standard 模版的
main.template 和 post.template
有個 $OnMainPage 變數
已記錄
ted
一般會員
***
文章: 103


檢視個人資料
« 回覆文章 #4 於: 十一月 10, 2006, 08:01:28 上午 »

謝謝 hsuzy 的回覆,

我在 post.template 加上了 $OnMainPage  的判斷, 結果不論是首頁或文章分類通通都一樣的顯示, 好像 $OnMainPage  抓不到或還怎樣

我的 code 如下

<!-- {$url->postTrackbackLink($post)} -->
{if $OnMainPage}
{assign var="postDate" value=$post->getDateObject()}
{assign var="postOwner" value=$post->getUserInfo()}
<DIV class=post>
<H2 class=storytitle ><A class=aposted href="{$url->postPermalink($post)}">{$post->getTopic()}</A></H2>
<DIV class=date>Published on {$locale->formatDate($postDate,"%H:%M, %m/%d,%Y")}</DIV>
<DIV class=storycontent>
<P>{$post->getText()}</P>
</DIV><BR>
<DIV class=feedback>
<DIV class=meta>Posted under
{foreach name=categories from=$post->getCategories() item=postcategory}
<a href="{$url->categoryLink($postcategory)}">{$postcategory->getName()}</a>
{if !$smarty.foreach.categories.last}, {/if}
{/foreach}
| <A  href="{$url->postPermalink($post)}#comments">{$locale->tr("comment on this")} ({$post->getTotalComments()})</A>
</DIV>
</DIV>
<DIV class=sep></DIV>
</DIV>

{else}

{assign var="postDate" value=$post->getDateObject()}
<p>
<A class=aposted href="{$url->postPermalink($post)}">{$post->getTopic()}</A> ({$locale->formatDate($postDate,"%Y/%m/%d,%H:%M")})<br/>
</p>
{/if}

已記錄

OS: windows server 2003
Apache Web Server Version 2.2.2
PHP Script Language Version 5.1.4
MySQL Database Version 5.0.22
hsuzy
新手見習
*
文章: 41


檢視個人資料
« 回覆文章 #5 於: 十一月 11, 2006, 02:03:46 上午 »

呃, 我似乎沒說清楚

main.template 的第一行

{assign var="OnMainPage" value=1}

這是關鍵, 因為 $OnMainPage 的宣告和初值 ...

所以你的 main.template 也要有這行, post.template的判斷才有意義
已記錄
ted
一般會員
***
文章: 103


檢視個人資料
« 回覆文章 #6 於: 十一月 11, 2006, 05:05:55 下午 »

謝謝 hsuzy 的提醒

但在我在 main.template 的第一行加了 {assign var="OnMainPage" value=1} 之後, 結果還是一樣
本以為是 template cache 的問題, 但我把 tmp 下的通通砍掉, 還是無法顯示出清單 ???




已記錄

OS: windows server 2003
Apache Web Server Version 2.2.2
PHP Script Language Version 5.1.4
MySQL Database Version 5.0.22
hsuzy
新手見習
*
文章: 41


檢視個人資料
« 回覆文章 #7 於: 十一月 11, 2006, 09:36:48 下午 »

sorry, 我好像來亂的, 我那個說法是錯的  嚎啕大哭

上面提到的 !$OnMainPage 那個只能適用

main.template 嵌入 post.template 和 postandcomments.template 嵌入 post.template
二者不同的判斷..

如果要做到分類目錄下只列文章標題
請參考 1.1 的 standard 樣版中 main.template
程式碼:
{if $category}<h2>{$locale->tr("category")}: {$category->getName()}</h2>{/if}
 
{foreach from=$posts item=post}
{if $showAll | 1 && $category}
  <!-- showing only the topic of the post, in case we have too many! -->
<h3><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h3>
<div>
{$post->getText()|strip_tags|truncate:300:"...":false}
</div>

<p class="footer">
{foreach name=categories from=$post->getCategories() item=postCategory}
  <a href="{$url->categoryLink($postCategory)}">{$postCategory->getName()}</a>{if !$smarty.foreach.categories.last}, {/if}
{/foreach}
</p>
{else}
藉由判斷有沒有 $category 變數...
已記錄
ted
一般會員
***
文章: 103


檢視個人資料
« 回覆文章 #8 於: 十一月 13, 2006, 08:26:45 下午 »

謝謝 微笑
已記錄

OS: windows server 2003
Apache Web Server Version 2.2.2
PHP Script Language Version 5.1.4
MySQL Database Version 5.0.22
Nyserq
新手見習
*
文章: 29


檢視個人資料 個人網站
« 回覆文章 #9 於: 十二月 11, 2006, 11:07:46 上午 »

對不起,我有點不太了解
判斷$cateogry變數,那是不是說$showAll變數沒有用了?
裏面的"$showAll | 1"又是什麼意思呢?
如果我要判斷是否是月份彙整要怎麼做呢?

又,設成首頁文章顯示數量,我設成5篇。
結果現在1.1版本,所有的包括分類頁面和日期彙整都只顯示5篇了。
是不是有了分頁功能後就沒有show all這個東西了?
已記錄

http://blogoncinema.dyndns.org/
LifeType 1.2.5
Apache 1.3.39(Unix), PHP 5.2.4, MySQL 5.0.45-community
頁: [1]
LifeType 中文開發論壇  |  開發  |  模版設計  |  該如何在顯示文章列表? « 上篇主題 下篇主題 »
    前往: