歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 24, 2024, 10:49:46 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  支援  |  使用與操作  |  [社群]在管理介面顯示文章點閱數 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: [社群]在管理介面顯示文章點閱數  (閱讀 6229 次)
jeanytu
初級會員
**
文章: 65


天天保持好心情


檢視個人資料
« 於: 八月 30, 2006, 02:05:40 下午 »

不知道有沒有人分享過,如果重複或發錯版,請刪除;
內容有誤,也歡迎指正,謝謝!

不少 LifeTyper 都對點閱數頗關心,
現行方式多是透過模板設計,在前端顯示點閱數,
http://forum.lifetype.org.tw/index.php?topic=1414.0

但對社群管理者來說,修改全域模板會影響全部的人,
並不是所有人都想在前端顯示點閱數;
也不是想顯示點閱數的人,便願意學會修改模板,
因此我希望能如同 CM(comment)、TB(trackback) 的數量,
PV(pageview) 也能顯示在管理介面中,這樣比較折衷。

其實方法還是一樣(在模板加上{$post->getNumReads ()}),只是應用的地方不同。

1. 打開 *\templates\admin\editposts.template

2. 找到 CM、TB 的語法
引用
<th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('postsList');" /></th>
<th style="width:345px;">{$locale->tr("topic")}</th>
<th style="width:115px;">{$locale->tr("date")}</th>
<th style="width:90px;">{$locale->tr("author")}</th>
<th style="width:60px;">{$locale->tr("status")}</th>
<th style="width:30px; text-align:center;">CM</th>
<th style="width:30px; text-align:center;">TB</th>

<th style="width:95px;">{$locale->tr("actions")}</th>

3. 插入 PV 的欄位
引用
<!-- 775 -->
<th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('postsList');" /></th>
<th style="width:345px;">{$locale->tr("topic")}</th>
<th style="width:115px;">{$locale->tr("date")}</th>
<th style="width:90px;">{$locale->tr("author")}</th>
<th style="width:60px;">{$locale->tr("status")}</th>
<th style="width:30px; text-align:center;">CM</th>
<th style="width:30px; text-align:center;">TB</th>

<th style="width:30px; text-align:center;">PV</th>
<th style="width:95px;">{$locale->tr("actions")}</th>

4. 最上面一行註記的<!-- 775 -->, 是指這個表格的寬度,
    但因為多一個 PV 欄位,所以要從其他欄位偷點空間 吐舌頭
    這部分請自行視情況調整(例如:我覺得標題太寬、日期太擠),
    也可以最後再來微調,請記得 width 總和要為 775 唷!
    下面是我調整後的版本:
引用
<!-- 775 -->
<th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('postsList');" /></th>
<th style="width:310px;">{$locale->tr("topic")}</th>
<th style="width:135px;">{$locale->tr("date")}</th>
<th style="width:75px; text-align:center;">{$locale->tr("author")}</th>
<th style="width:40px;">{$locale->tr("status")}</th>
<th style="width:40px; text-align:center;">CM</th>
<th style="width:40px; text-align:center;">TB</th>
<th style="width:50px; text-align:center;">PV</th>
<th style="width:75px;">{$locale->tr("actions")}</th>

5. 再往下拉,找到顯示 TB 數的語法
引用
<td style="text-align: center;">
{if $post->getTotalTrackbacks() > 0}
<a href="?op=editTrackbacks&articleId={$post->getId()}">({$post->getTotalTrackbacks()})</a>
{else}
0
{/if}
</td>
<td>
<div class="list_action_button">
<a href="?op=editPost&amp;postId={$post->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" /></a>
<a href="?op=deletePost&amp;postId={$post->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
<a href="?op=postStats&amp;postId={$post->getId()}"><img src="imgs/admin/icon_stats-16.png" alt="{$locale->tr("statistics")}" /></a>
</div>
</td>

6. 插入顯示 PV 數的語法
引用
<td style="text-align: center;">
{if $post->getTotalTrackbacks() > 0}
<a href="?op=editTrackbacks&articleId={$post->getId()}">({$post->getTotalTrackbacks()})</a>
{else}
0
{/if}
</td>
<td style="text-align: center;">{$post->getNumReads()}</td>
<td>
<div class="list_action_button">
<a href="?op=editPost&amp;postId={$post->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" /></a>
<a href="?op=deletePost&amp;postId={$post->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
<a href="?op=postStats&amp;postId={$post->getId()}"><img src="imgs/admin/icon_stats-16.png" alt="{$locale->tr("statistics")}" /></a>
</div>
</td>

7. 存檔後,即可由管理介面的 [文章列表] 中看到 PV 數囉!

補充說明
如果你想要提前讓 CM、TB、PV 顯示中文
http://forum.lifetype.org.tw/index.php?topic=1894.0

請自行在 *\locale\locale_zh_TW.php
新增對應的翻譯,例如:
$messages['CM'] = '迴響';
$messages['TB'] = '引用';
$messages['PV'] = '瀏覽';

然後將欄位名稱修改如下:
引用
<!-- 775 -->
<th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('postsList');" /></th>
<th style="width:310px;">{$locale->tr("topic")}</th>
<th style="width:135px;">{$locale->tr("date")}</th>
<th style="width:75px; text-align:center;">{$locale->tr("author")}</th>
<th style="width:40px; text-align:center;">{$locale->tr("status")}</th>
<th style="width:40px; text-align:center;">{$locale->tr("CM")}</th>
<th style="width:40px; text-align:center;">{$locale->tr("TB")}</th>
<th style="width:50px; text-align:center;">{$locale->tr("PV")}</th>
<th style="width:75px;">{$locale->tr("actions")}</th>
« 最後編輯時間: 八月 30, 2006, 02:14:52 下午 由 jeanytu » 已記錄

LifeType 1.1.2(直接安裝,非升級)+ AppServ 2.5.7 + Windows XP
Apache:2.2.3
PHP:5.1.6
MySQL:5.0.24a
頁: [1]
LifeType 中文開發論壇  |  支援  |  使用與操作  |  [社群]在管理介面顯示文章點閱數 « 上篇主題 下篇主題 »
    前往: