歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 29, 2024, 03:15:32 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  模版設計  |  如何將個人圖像寫入模版? « 上篇主題 下篇主題 »
頁: [1] 2
作者 主題: 如何將個人圖像寫入模版?  (閱讀 30000 次)
Jas
新手見習
*
文章: 10


檢視個人資料 個人網站
« 於: 四月 07, 2005, 09:11:29 上午 »

我想請問一個問題關於:如何將個人圖像寫入模版。
 
個人網誌設定 » 網誌作家設定  裡有個人圖像功能,
可以提供User客製自訂個人大頭肖像,
不過,
目前,個人圖像似乎只出現在summary這個模版的UserList頁面上,
其他的模版都沒有概括進去,
我猜想這可能是因為個人圖像是1.0才新增的,
而目前的模版大致上都是沿用0.3x的緣故吧,
我試過直接把summary裡的語法直接拿到自訂模版去用,
結果根本不管用,
不曉得有沒有人能提供個人圖像寫入模版的正確解法?
 
謝謝!
已記錄
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #1 於: 四月 07, 2005, 11:29:06 上午 »

你試試看

程式碼:
{if $user->hasPicture()} 
{assign var=userPicture value=$user->getPicture()}
<img alt="Picture" src="{$url->resourcePreviewLink($userPicture)}" id="userPicture"  style="display:block;margin-left:auto;margin-right:auto" />
{/if}


Mark

** $user 是新的 object,應該可以用在所有的 template 中
** $user->hasPicture() 是用來判斷是不是使用者已經設定大頭貼了
** $user->getPicture() 會傳回 resource 的物件。
已記錄

Anonymous
訪客
« 回覆文章 #2 於: 四月 07, 2005, 02:37:04 下午 »

謝謝mark的回覆,
其實我先前就是這樣試的,
結果會出現:
程式碼:
Fatal error: Call to a member function on a non-object in /home/crescent/public_html/plog/tmp/2/%%-11^%%-1198881322^header.template.php on line 53

照著錯誤訊息查看我的模版在45行至60行之間的語碼:
程式碼:
<p>{if !empty($karma)}
{if $karma->isEnabled()}
<li><a title="{$locale->tr("karma_moderated_down_articles")}" href="{$karma->pluginTemplatePage()}">{$locale->tr("karma_moderated_down_articles")}</a></li>
{/if}
{/if}</p>
{if $topcommentvisitors->isEnabled()}
<div class="Sidetitle">
<h4>最踴躍回應訪客</h4>
</div>
<ul>  
{assign var=commentvisitors value=$topcommentvisitors->getTopCommentVisitors()}
{foreach from=$commentvisitors item=commentvisitor}
<li><a href="{$commentvisitor.user_url}">{$commentvisitor.user_name} ({$commentvisitor.user_count} Comments)</a></li>
{/foreach}
</ul>    
{/if}

看起來並沒有讓前一段語法出現錯誤的東西,
照理說mark提的這種方式應該可行,
不過每一次都遇到Fatal error: Call to a member function on a non-object
已記錄
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #3 於: 四月 07, 2005, 02:46:53 下午 »

不不.... 在編譯後的 /home/crescent/public_html/plog/tmp/2/%%-11^%%-1198881322^header.template.php  第 53 行錯誤,不代表在 header.templaye 的 53 行錯誤,可能是第 20 錯的。

因為編譯過後的是 PHP 程式,而非模版。

你的網站在哪,能看我看一下嗎?另外可以把模版你修改的部分完整的 post 上來嗎?

Mark
已記錄

markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #4 於: 四月 07, 2005, 02:59:02 下午 »

引用自: markwu
不不.... 在編譯後的 /home/crescent/public_html/plog/tmp/2/%%-11^%%-1198881322^header.template.php  第 53 行錯誤,不代表在 header.templaye 的 53 行錯誤,可能是第 20 錯的。

因為編譯過後的是 PHP 程式,而非模版。

你的網站在哪,能看我看一下嗎?另外可以把模版你修改的部分完整的 post 上來嗎?

Mark


另外我剛剛看了一下程式,不是你的問題,而是 $user 物件沒傳出來 ...mmm... 我想想。

Mark
已記錄

markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #5 於: 四月 07, 2005, 10:12:29 下午 »

Hi Jas:

我找出原因了!是 bug .. 我在修。

Mark
已記錄

Jas
新手見習
*
文章: 10


檢視個人資料 個人網站
« 回覆文章 #6 於: 四月 08, 2005, 08:59:13 上午 »

辛苦你了,
mark
希望這個問題不至於太麻煩而增加你的負擔,
不過我也在想,
如果個人圖像也顯示在個人模版上,
那麼整個頁面的個人化風格會更強一些,
相信這會是pLog未來推廣的一大利多,
因為它的後台操作實在是太便利了,
總之,謝啦!
已記錄
Jas
新手見習
*
文章: 10


檢視個人資料 個人網站
« 回覆文章 #7 於: 四月 18, 2005, 09:41:56 上午 »

這個問題解決了。

如果有也有人想在模版上加入個人圖像,
作法是將以下語法貼到你想要秀出個人圖像的地方即可:
程式碼:
{assign var=blogOwner value=$blog->getOwnerInfo()}
{if $blogOwner->hasPicture()}
  {assign var=picture value=$blogOwner->getPicture()}
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$blogOwner->getUsername()}" />
{/if}


如果怕有人上傳了尺寸太大的圖而破壞畫面,
可以在img標籤裡加入尺寸參數比方說:
程式碼:
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$blogOwner->getUsername()}" width="80" height="80"/>

就樣就萬無一失了。
已記錄
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #8 於: 四月 18, 2005, 09:50:18 上午 »

引用自: Jas
這個問題解決了。

如果有也有人想在模版上加入個人圖像,
作法是將以下語法貼到你想要秀出個人圖像的地方即可:
程式碼:
{assign var=blogOwner value=$blog->getOwnerInfo()}
{if $blogOwner->hasPicture()}
  {assign var=picture value=$blogOwner->getPicture()}
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$blogOwner->getUsername()}" />
{/if}


如果怕有人上傳了尺寸太大的圖而破壞畫面,
可以在img標籤裡加入尺寸參數比方說:
程式碼:
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$blogOwner->getUsername()}" width="80" height="80"/>

就樣就萬無一失了。


Ah ....Jas,抱歉! 我一直忘了回復這個問題。如 Jas 說的,透過 blogownerinfo就可以了!我在 templte 中加入一個新的物件,叫做 owner,所以在 1.01 (開發中),直接以 owner 來作就可以了!不需要再經過 $blog->getOwnerInfo 來取得 owner 的 information.

{if $owner->hasPicture()}
  {assign var=picture value=$owner->getPicture()}
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$owner->getUsername()}" />
{/if}

有興趣可以透過 SVN 直接取得 1.0.1 的開發程式碼!

http://devel.lifetype.net/svn/plog/plog/branches/plog-1.0.1


Mark
已記錄

yufeng
新手見習
*
文章: 39


檢視個人資料
« 回覆文章 #9 於: 一月 11, 2006, 11:45:27 下午 »

hi,markwu 你好, 我的lifetype是1.0.2版本,也遇到了这个问题...

我试验了你的方法, 如果只在panel.template中加入
程式碼:
{if $owner->hasPicture()}
  {assign var=picture value=$owner->getPicture()}
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$owner->getUsername()}" />
{/if}
在首页是正常的,但是进入其他页面,如comment,还是会出错的,
但是在前面加入
程式碼:
{assign var=owner value=$blog->getOwnerInfo()}
就好了, 好像是文件没有完全包含进来 微笑
已記錄

服务器环境:
LINUX RH ES3/PHP 4.4.0/MySQL 4.1.11/Apache 2.0.54
======================
调试环境:
Win2003/PHP 4.4.1/MySQL 4.1.11/Apache 2.0.54
3gboke
初級會員
**
文章: 81


檢視個人資料
« 回覆文章 #10 於: 一月 20, 2006, 04:03:05 上午 »

hi ,,我也修改了.  不过也有yufeng 报告的情况, 按照yufeng的方式添加了,, 在回复评论页面处出现错误.

我在panel中修改添加代码如下:
{assign var=owner value=$blog->getOwnerInfo()}
{if $owner->hasPicture()}
  {assign var=picture value=$owner->getPicture()}
  <img src="{$url->resourcePreviewLink($picture)}" alt="{$owner->getUsername()}" width="180" height="160"/>
{/if}
<div class="sidetitle">关于作者</div>
 <div class="side">
{assign var=blogOwner value=$blog->getOwnerInfo()}
{if $blogOwner->getAboutMyself()}
<P>{$blogOwner->getfullName()}</P>
<P>{$blogOwner->getAboutMyself()}</P>
{/if}
</div>


但是在发表评论的页面初出现错误. 而在其他页面并无错误.
错误代码为:     

Fatal error: Call to a member function isEnabled() on a non-object in E:\AppServ\www\lifetype\tmp\1\%%-66^%%-66376128^commentform.template.php on line 30
已記錄

偶不懂PHP程式,对LT的修改仅限于其模板的修改
markwu
系統管理員
超級會員
*****
文章: 3928


Mark Wu


檢視個人資料 個人網站
« 回覆文章 #11 於: 一月 20, 2006, 08:46:05 上午 »

你可以簡化成:

{assign var=owner value=$blog->getOwnerInfo()}
{if 
$owner->hasPicture()}
  {
assign var=picture value=$owner->getPicture()}
  <
img src="{$url->resourcePreviewLink($picture)}alt="{$owner->getUsername()}width="180" height="160"/>
{/if}
<
div class="sidetitle">关于作者</div>
 <
div class="side">
{if 
$owner->getAboutMyself()}
<
P>{$owner->getFullName()}</P>
<
P>{$owner->getAboutMyself()}</P>
{/if}
</
div>

BTW, 是你的 getFullName() 大小寫寫錯了!

Mark
已記錄

3gboke
初級會員
**
文章: 81


檢視個人資料
« 回覆文章 #12 於: 一月 20, 2006, 05:59:47 下午 »

 目瞪口呆     汗ing     是smileys 插件引起的..  删除就OK了
已記錄

偶不懂PHP程式,对LT的修改仅限于其模板的修改
niveko
新手見習
*
文章: 34


檢視個人資料
« 回覆文章 #13 於: 三月 19, 2006, 01:03:13 上午 »

Hi Mark:

根据你的代码“<img src="{$url->resourcePreviewLink($picture)}" alt="{$owner->getUsername()}" width="180" height="160"/>”
那取得的图片是Preview的,在经过width="180" height="160" 就会使得图片不清楚了! 请问你有没有办法取得原来大小的图片呢?还有怎么可以得到原来图片大小的真实象素!谢谢!

已記錄
lss
我不是被~拉~~出來的,不要叫我大大!
總版主
超級會員
*****
文章: 1511



檢視個人資料 個人網站
« 回覆文章 #14 於: 三月 19, 2006, 01:25:00 上午 »

Hi Mark:

根据你的代码“<img src="{$url->resourcePreviewLinkresourceDownloadLink($picture)}" alt="{$owner->getUsername()}" width="180" height="160"/>”
那取得的图片是Preview的,在经过width="180" height="160" 就会使得图片不清楚了! 请问你有没有办法取得原来大小的图片呢?还有怎么可以得到原来图片大小的真实象素!谢谢!


已記錄

沒找過 常見問題集或不知道 如何在 LifeType 中文開發論壇發問的人,恕不回答問題
頁: [1] 2
LifeType 中文開發論壇  |  開發  |  模版設計  |  如何將個人圖像寫入模版? « 上篇主題 下篇主題 »
    前往: