歡迎光臨, 訪客. 請先 登入註冊一個帳號.
三月 28, 2024, 05:11:14 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  外掛程式  |  如何在Dabu模版加入「置頂文章」的語法 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 如何在Dabu模版加入「置頂文章」的語法  (閱讀 14006 次)
quintin
新手見習
*
文章: 14


檢視個人資料 個人網站
« 於: 五月 26, 2005, 06:03:29 上午 »

我已經啟動了置頂文章的Plug-in。使用的模版是Dabu,但是因為跟Plog wiki上面舉的模版Bluish不太一樣,所以我試了幾次,總是踢到鐵板,不得其法。我猜測應該是處理main.template的模版吧?所以我把我的模版的main.template內容轉貼如下:

{include file="$blogtemplate/header.template"}
<div id="Content">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
{include file="$blogtemplate/main_left.template"}
</td>

<td id="Main" valign="top">
<!-- ######### Template:: Page original contents  ######### -->

<br/>{$blog->getAbout()}

{foreach from=$posts item=post}
{include file="$blogtemplate/post.template"}
{/foreach}

<!--// ######### Template:: Page original contents  ######### -->
</td>

<td valign="top">
{include file="$blogtemplate/main_right.template"}
</td>
</tr>
</table>
</div>
{include file="$blogtemplate/footer.template"}

不知道哪為仁兄可以幫忙我一下!謝謝..
已記錄
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #1 於: 五月 26, 2005, 07:07:45 上午 »

hi quintin:

假設你是要把置頂和公告放在中間欄的最上面,那就……
引用自: quintin

{include file="$blogtemplate/header.template"}
<div id="Content">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
{include file="$blogtemplate/main_left.template"}
</td>

<td id="Main" valign="top">
<!-- ######### Template:: Page original contents  ######### -->
{*把置頂的 template 加在這裡*}
<br/>{$blog->getAbout()}

{foreach from=$posts item=post}
{include file="$blogtemplate/post.template"}
{/foreach}

<!--// ######### Template:: Page original contents  ######### -->
</td>

<td valign="top">
{include file="$blogtemplate/main_right.template"}
</td>
</tr>
</table>
</div>
{include file="$blogtemplate/footer.template"}
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
Quintintaiwan
訪客
« 回覆文章 #2 於: 五月 26, 2005, 01:57:14 下午 »

謝謝lss喔...不過我把下面這段語法,貼到你說要加入的地方....會出現下列的錯誤訊息:
Exception message: Smarty error: [in dabu/main.template line 50]: syntax error: unclosed tag {if} (opened line 30). (Smarty_Compiler.class.php, line 303)
Error code: 256
-- Backtrace --
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1108): trigger_error
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1870): smarty_compiler.trigger_error
/usr/local/www/plog/class/template/smarty/Smarty_Compiler.class.php(2123): smarty_compiler._trigger_fatal_error
/usr/local/www/plog/class/template/smarty/Smarty_Compiler.class.php(303): smarty_compiler._syntax_error
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1506): smarty_compiler._compile_file
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1441): cachedtemplate._compile_source
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1279): cachedtemplate._compile_resource
/usr/local/www/plog/class/template/cachedtemplate.class.php(48): smarty.fetch
/usr/local/www/plog/class/view/smartyview.class.php(190): cachedtemplate.fetch
/usr/local/www/plog/class/view/blogview.class.php(212): smartyview.render
/usr/local/www/plog/class/view/defaultview.class.php(82): blogview.render
/usr/local/www/plog/class/controller/controller.class.php(325): defaultview.render
/usr/local/www/plog/index.php(68): blogcontroller.process

Exception message: Smarty error:
Error code: 512
-- Backtrace --
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1108): trigger_error
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1454): cachedtemplate.trigger_error
/usr/local/www/plog/class/template/smarty/Smarty.class.php(1279): cachedtemplate._compile_resource
/usr/local/www/plog/class/template/cachedtemplate.class.php(48): smarty.fetch
/usr/local/www/plog/class/view/smartyview.class.php(190): cachedtemplate.fetch
/usr/local/www/plog/class/view/blogview.class.php(212): smartyview.render
/usr/local/www/plog/class/view/defaultview.class.php(82): blogview.render
/usr/local/www/plog/class/controller/controller.class.php(325): defaultview.render
/usr/local/www/plog/index.php(68): blogcontroller.process


下面是我轉貼自Plog wiki上的語法:
{if $stickyposts->isEnabled()}
  <h2>Sticky Posts</h2>
  {assign var=stickys value=$stickyposts->getArticles('sticky')}
  {foreach from=$stickys item=post}
      <h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
  {/foreach}
  {assign var=stickyCategory value=$stickyposts->getCategory('sticky')}
  <h4><a href="{$url->categoryLink($stickyCategory)}">more sticky posts</a></h4>
 
  <h2>Announce Posts</h2>
  {assign var=stickys value=$stickyposts->getArticles('announce')}
  {foreach from=$stickys item=post}
      <h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
  {/foreach}
  {assign var=announceCategory value=$stickyposts->getCategory('announce')}
  <h4><a href="{$url->categoryLink($announceCategory)}">more announce posts</a></h4>
{/if}  
  {foreach from=$posts item=post}
    {include file="$blogtemplate/post.template"}
  {/foreach}


不知道哪裡又出了錯誤,可能還需要指導一下。謝謝~~
已記錄
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #3 於: 五月 26, 2005, 04:25:33 下午 »

hi quintin:

你能把整個 main.template 貼出來嗎?這樣比較好處理。
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
quintin
新手見習
*
文章: 14


檢視個人資料 個人網站
« 回覆文章 #4 於: 五月 26, 2005, 10:06:32 下午 »

我的Main.template全部內容如下:

{include file="$blogtemplate/header.template"}
<div id="Content">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
{include file="$blogtemplate/main_left.template"}
</td>

<td id="Main" valign="top">
<!-- ######### Template:: Page original contents  ######### -->

<br/>{$blog->getAbout()}

{foreach from=$posts item=post}
{include file="$blogtemplate/post.template"}
{/foreach}

<!--// ######### Template:: Page original contents  ######### -->
</td>

<td valign="top">
{include file="$blogtemplate/main_right.template"}
</td>
</tr>
</table>
</div>
{include file="$blogtemplate/footer.template"}

{if !empty($blogtimes)}
{if $blogtimes->isEnabled()}
{$blogtimes->show()}
{/if}
{/if}

還請lss費心了!真是感謝阿....
已記錄
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #5 於: 五月 27, 2005, 03:48:05 下午 »

hi quintin:

為了測試,我特別裝了 dabu 模版,一切都正常,不知道為什麼你會出問題?! 挑眉質疑  挑眉質疑

記得,wiki 上的樣版示範裡,最下面三行:
程式碼:
{foreach from=$posts item=post}
{include file="$blogtemplate/post.template"}
{/foreach}


是原本就在 bluish 模版裡的,不要重複貼入了。
已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
quintin
新手見習
*
文章: 14


檢視個人資料 個人網站
« 回覆文章 #6 於: 五月 27, 2005, 10:21:18 下午 »

to lss,我貼完之後的內容如下:

{include file="$blogtemplate/header.template"}
<div id="Content">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
{include file="$blogtemplate/main_left.template"}
</td>

<td id="Main" valign="top">
<!-- ######### Template:: Page original contents  ######### -->

{if $showAll}
{if $stickyposts->isEnabled()}
<h2>Sticky Posts</h2>
{assign var=stickys value=$stickyposts->getArticles('sticky')}
{foreach from=$stickys item=post}
<h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
{/foreach}
{assign var=stickyCategory value=$stickyposts->getCategory('sticky')}
<h4><a href="{$url->categoryLink($stickyCategory)}">more sticky posts</a></h4>

<h2>Announce Posts</h2>
{assign var=stickys value=$stickyposts->getArticles('announce')}
{foreach from=$stickys item=post}
<h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
{/foreach}
{assign var=announceCategory value=$stickyposts->getCategory('announce')}
<h4><a href="{$url->categoryLink($announceCategory)}">more announce posts</a></h4>
{/if}
{if $showAll}


<br/>{$blog->getAbout()}

{foreach from=$posts item=post}
{include file="$blogtemplate/post.template"}
{/foreach}

<!--// ######### Template:: Page original contents  ######### -->
</td>

<td valign="top">
{include file="$blogtemplate/main_right.template"}
</td>
</tr>
</table>
</div>
{include file="$blogtemplate/footer.template"}

{if !empty($blogtimes)}
{if $blogtimes->isEnabled()}
{$blogtimes->show()}
{/if}
{/if}


結果還是一樣不幸阿 ...鐵定是我哪裡弄錯了~~
已記錄
fragileness
新手見習
*
文章: 33


檢視個人資料
« 回覆文章 #7 於: 五月 28, 2005, 02:58:48 上午 »

你早該貼這一份出來的...

引用自: quintin
to lss,我貼完之後的內容如下:

{include file="$blogtemplate/header.template"}
<div id="Content">
<table border="0" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
{include file="$blogtemplate/main_left.template"}
</td>

<td id="Main" valign="top">
<!-- ######### Template:: Page original contents  ######### -->

{if $showAll}
{if $stickyposts->isEnabled()}
<h2>Sticky Posts</h2>
{assign var=stickys value=$stickyposts->getArticles('sticky')}
{foreach from=$stickys item=post}
<h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
{/foreach}
{assign var=stickyCategory value=$stickyposts->getCategory('sticky')}
<h4><a href="{$url->categoryLink($stickyCategory)}">more sticky posts</a></h4>

<h2>Announce Posts</h2>
{assign var=stickys value=$stickyposts->getArticles('announce')}
{foreach from=$stickys item=post}
<h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
{/foreach}
{assign var=announceCategory value=$stickyposts->getCategory('announce')}
<h4><a href="{$url->categoryLink($announceCategory)}">more announce posts</a></h4>
{/if}
{if $showAll}



上面最後一行這個 {if $showAll} 應該是多餘的吧。
一個{if $showAll}配一個{/if}來close就好了
你後面又多加了一個{if $showAll},所以錯誤訊息裡才會說你又少了一個{/if}來做close的動作
還有,被{if $showAll}{/if}包起來的東西是「不在首頁的時候」會顯示的
如果你要「只在首頁顯示」要改一下,
請翻閱 http://forum.lifetype.org.tw/index.php?topic=657.0
已記錄
quintin
新手見習
*
文章: 14


檢視個人資料 個人網站
« 回覆文章 #8 於: 五月 28, 2005, 06:44:32 上午 »

謝謝lss和fragilness的大力幫忙,沒想到被我胡問一通,還是有這麼熱心的人在幫忙。之前Fragilness的文章,其實我有看到,只不過不太懂在說什麼,現在似乎比較有感覺了。謝謝兩位的幫忙~~~這樣似乎可以運作了~~
已記錄
頁: [1]
LifeType 中文開發論壇  |  開發  |  外掛程式  |  如何在Dabu模版加入「置頂文章」的語法 « 上篇主題 下篇主題 »
    前往: