歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 27, 2024, 09:00:39 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  模版設計  |  如何每個分類文章頁面頂端都會不同的FLASH或圖片 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 如何每個分類文章頁面頂端都會不同的FLASH或圖片  (閱讀 13284 次)
kangfong
新手見習
*
文章: 1


檢視個人資料
« 於: 十月 16, 2005, 11:15:17 下午 »

幫幫我~ :'(當我點不同的文章分類時,如何讓每個頁面頂端的FLASH都會變換不同的主題,
我試著在header.template的尾端加上這段
程式碼:
{if ($postCategoryId==2)}
<embed src="{$url->getTemplateFile("images/001.swf")}" quality="high" type="application/x-shockwave-flash" width="766" height="250"> </embed>
{elseif ($postCategoryId==3)}
<embed src="{$url->getTemplateFile("images/002.swf")}" quality="high" type="application/x-shockwave-flash" width="766" height="250"> </embed>
{elseif ($postCategoryId==4)}
<embed src="{$url->getTemplateFile("images/003.swf")}" quality="high" type="application/x-shockwave-flash" width="766" height="250"> </embed>
{/if}
可是我發現$postCategoryId的值並沒有隨著點選不的分類文章連結而有所改變
{if ($postCategoryId==2)} 這段,我應該如下手啊,救救我吧~
已記錄
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #1 於: 十月 17, 2005, 11:01:31 上午 »

你的 $postCategoryId 是在哪裡宣告的呢?如果你沒有宣告過 $postCategoryId ,那麼當然他的值是空的。另外,這一段是你從哪裡看來的呢?光這樣是不會 work 的啊!

你試試看,在 post.template 的中加入紅色的那幾行

{foreach name=categories from=$post->getCategories() item=postCategory}
  {if $smarty.foreach.categories.first}
    {assign var="postCategoryId " value=$postCategory->geId()}
  {/if}

  <a href="{$url->categoryLink($postCategory)}">
    {$postCategory->getName()}</a>{if
      !$smarty.foreach.categories.last}, {/if}
{/foreach}

目的是在 post.template 中宣告 postCategoryId ,以方便等一下在 header.template 用。

Mark
已記錄

bluestar0217
新手見習
*
文章: 2


檢視個人資料
« 回覆文章 #2 於: 十二月 29, 2005, 10:50:44 下午 »

我照了上面的用法 做了一次 都不行丫!    上面有一行少了   !     ,我改了後  發現postCategoryId 好像是空的 沒有資料 
  因為我用  if ($postCategoryId== '' )}
 <EMBED SRC=http://........../flash/11.swf  WIDTH=740 HEIGHT=145 wmode=transparent quality=high loop=true align=middle menu=false type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer> </embed>
 有flash
但postCategoryId 都不會變
!!
不知道這問題 有人解決了嗎???
感激!!!
已記錄
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #3 於: 十二月 29, 2005, 11:48:02 下午 »

..................
目的是在 post.template 中宣告 postCategoryId ,以方便等一下在 header.template 用。

Mark
hi mark:

header.template 是在 post.template 之前就被引入 main.template 了,所以 header.template 用不到這個 postCategoryId 。

這裡可以用
引用
{if $smarty.request.postCategoryId=="1"}
的寫法來達成。在我的 blog 有比較詳細的說明( 在模版裡調用 PHP 的 Request 變數)。懶得再貼一遍了  吐舌頭

lss
已記錄

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


檢視個人資料
« 回覆文章 #4 於: 十二月 30, 2005, 02:52:11 下午 »

謝謝!! 成功了!
已記錄
頁: [1]
LifeType 中文開發論壇  |  開發  |  模版設計  |  如何每個分類文章頁面頂端都會不同的FLASH或圖片 « 上篇主題 下篇主題 »
    前往: