Porting Templates

Porting Templates

出自LifeType 中文文件計畫

(修訂版本間差異)
跳轉到: 導航, 搜尋
(檔案分頁)
(檔案分頁)
第54行: 第54行:
在這個例子中不同的是 $resources 這個陣列已經被預設為在該頁面中會顯示的檔案,但在之前的版本中,該陣列會載入該資料夾中所有的檔案。站在系統效能的觀點來看,這應該是比較好的解決方法。
在這個例子中不同的是 $resources 這個陣列已經被預設為在該頁面中會顯示的檔案,但在之前的版本中,該陣列會載入該資料夾中所有的檔案。站在系統效能的觀點來看,這應該是比較好的解決方法。
-
Now in order to get the pager displayed, we have to apply the same solution that was applied for paged posts via '''misc/pager.template'''. The pager works in exactly the same way regardless of whether it is being used to page posts or resources so no extra changes are required.
+
接下來顯示分頁的方法,和文章分頁是一樣的,同樣是透過'''misc/pager.template'''這個檔案。不管是文章分頁或是檔案分頁,它們運作的原理都一樣,因此在分頁顯示這個部份並不需要額外的修改。
-
Somewhere in album.template, we will have a line like this:
+
album.template 檔案中的適當地方,加上下面的內容:
<pre>
<pre>
第62行: 第62行:
</pre>
</pre>
-
The location of the pager will depend on the current style of our page.
+
分頁顯示的位置,會依照目前頁面的樣式而定。
== 取得迴響和引用的正確數字 ==
== 取得迴響和引用的正確數字 ==

在2006年7月19日 (三) 08:25所做的修訂版本

目錄

移植模版到 LifeType 1.1

針對LifeType 1.0 設計的模版,在沒有移植的情況下,也可以正常的在LifeType 1.1版中使用。但是它可能無法使用最新的功能,例如:分頁功能。

下面的內容將提供給對移植模版感興趣的使用者做為參考,說明在模版移值的過程中,那些模版檔案是必需加以修改的。

文章分頁

LifeType 1.1會依據整個部落格、某個月份的匯整或是某個目錄下的文章或檔案數目,自動在首頁產生分頁。但是,我們必需使用一些額外的Smarty語法來顯示分頁。

顯示分頁最簡單的方式是將檔案misc/pager.template引用進來,該檔案已經包含所有顯示分頁必需的內容。

你可以在main.templatefooter.template的最底部(分頁顯示的確切位置,可能會依照模版的不同而有所差別)加入以下程式碼:

{include file="misc/pager.template" style="links"}

style 後的參數值可以使用下面的任何值來取代:

  • links 會顯示一個基本的水平樣式的分頁連結,包含 "Next" 和 "Prev" 的連結,這兩個連結顯示與否會依照目前頁數和全部頁數的關係而自動調整。
  • forwardonly 在必要的時候,只會顯示前往下一頁的連結(在最後一頁時則不顯示連結)。
  • backonly 在必要的時候,只會顯示往前一頁的連結(因此,在第一頁時則不顯示連結)。

底下是提供給分頁使用的CSS樣式名稱:

  • pagerLink: 分頁連結樣式。
  • pagerLinkPrevPage: "上一頁" 連結樣式。
  • pagerLinkNextPage: "下一頁" 連結樣式。
  • pagerCurrent: 目前所在頁面樣式(無連結樣式)。

以上這些樣式,應該夠用來設計一個符合模版整體設計的分頁外觀。不管未來是否有客製化的需要,你甚至可以使用上面不同的風格樣式來創造自己風格的分頁。

檔案分頁

和文章相同的,在LifeType 1.1中檔案也使用趕流行的分頁方式。

和文章不同的是,要讓檔案支援分頁顯示,必需對模版檔案做額外的修改。如果沒有加上這些修改,那麼將會得到和平常一樣沒分頁的效果,將所有的檔案全部在一個頁面中顯示出來。

album.template 檔案中找到以下的Smarty 程式碼:

{assign var=resources value=$album->getResources()}
{foreach from=$resources item=resource}

將它用以下的程式碼取代:

 {foreach from=$resources item=resource}

在這個例子中不同的是 $resources 這個陣列已經被預設為在該頁面中會顯示的檔案,但在之前的版本中,該陣列會載入該資料夾中所有的檔案。站在系統效能的觀點來看,這應該是比較好的解決方法。

接下來顯示分頁的方法,和文章分頁是一樣的,同樣是透過misc/pager.template這個檔案。不管是文章分頁或是檔案分頁,它們運作的原理都一樣,因此在分頁顯示這個部份並不需要額外的修改。

在 album.template 檔案中的適當地方,加上下面的內容:

{include file="misc/pager.template" style="links"}

分頁顯示的位置,會依照目前頁面的樣式而定。

取得迴響和引用的正確數字

Up to version 1.0 of LifeType, the call $post->getNumComments() returned the number of non-spam comments while $post->getTotalTrackbacks() returned the number of non-spam trackbacks. For consistency reasons, LifeType 1.1 fixes this issue and now the methods have been fixed:

  • $post->getTotalComments(): returns the number of non-spam comments.
  • $post->getTotalTrackbacks(): returns the number of non-spam trackbacks.
  • $post->getNumComments(): returns the total number of comments (both spam and non-spam)
  • $post->getNumTrackbacks(): returns the total number of trackbacks (both spam and non-spam)

When porting templates from LifeType 1.0.x to LifeType 1.1, please remember to replace all occurrences of getNumComments() with getTotalcomments() or else the comment counters will show confusing values.