Porting Templates

Porting Templates

出自LifeType 中文文件計畫

(修訂版本間差異)
跳轉到: 導航, 搜尋
(文章分頁)
(移植模版到 LifeType 1.1)
第4行: 第4行:
針對LifeType 1.0 設計的模版,在沒有移植的情況下,也可以正常的在LifeType 1.1版中使用。但是它可能無法使用最新的功能,例如:分頁功能。
針對LifeType 1.0 設計的模版,在沒有移植的情況下,也可以正常的在LifeType 1.1版中使用。但是它可能無法使用最新的功能,例如:分頁功能。
-
下面的內容將提供餒對移植模版感興趣的使用者做為參考,說明在模版移值的過程中,那些是在模版檔案中所必需做的修改。
+
下面的內容將提供給對移植模版感興趣的使用者做為參考,說明在模版移值的過程中,那些模版檔案是必需加以修改的。
== 文章分頁 ==
== 文章分頁 ==

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

目錄

移植模版到 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: 目前所在頁面樣式(無連結樣式)。

Usually it will enough to add the Smarty code listed above and make sure that the pager fits with the overall design of the page. In cases where further customization is needed, it is possible to use the different available styles and even create our own custom pager.

檔案分頁

As with articles, resources are also displayed in a paged fashion since LifeType 1.1.

Unlike with articles, it is necessary to make an additional change to our template in order to get a paged display of resources. If these changes are not made, we will get the normal non-paged display of resources where all of them are displayed in one single page.

In album.template find the following Smarty code:

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

And replace it with the following:

 {foreach from=$resources item=resource}

The difference in this case is tha the $resources array has already been preset wtih only the resources that should be displayed in this page, while the previous version will load all the resources in the album. From a performance point of view, it is also a better solution.

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.

Somewhere in album.template, we will have a line like this:

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

The location of the pager will depend on the current style of our page.

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

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.