以前在LifeType上有使用gallery這外掛(將gallery2整合進LifeType網誌裡修改gallery plugin),不過好久沒去注意這外掛的問題了。

這外掛的功能就是可以將Gallery2裡的照片內嵌在LifeType的版面上,實例可以看看我們教務處的網誌。 

剛好有人問gallery plugin的問題,才發現原來的外掛在LifeType上會有點小問題,所以就找了一些資料,順便再記錄一下。

1.下載gallery plugin:

我這邊LT版本為1.2.3,所以必須去下載for LT1.2的plugin。你可以到sourceforge這一頁,去下載「 1.2_gallery.zip」。

2.修改gallery plugin程式:

在論壇上之前有這篇文章「修正 LifeType 1.2 使用 Gallery 外掛無法顯示相簿的問題」,twu2已把修正檔案回報到 bugs lifetype 了,不過我今天下載那gallery的外掛,還沒修正這問題。

所以我們可以根據twu2的文章,自己手動修改一下程式。修改 /plugins/gallery/plugingallery.class.php,約第30行開始,下面紅色字部分就是要加入或修改的內容。

        // Setup the plugin information
        $this->id = "gallery";
        $this->author = "Laurent Vauthrin";
        $this->desc = "Integrates gallery2 into LifeType 1.2.";
        $this->version = "20070405";

        // Setup the locale
        $this->locales = Array( "en_UK" );

        if ($source == "admin")
            $this->initAdmin();
         else
          $this->init();

    }

 function init()
 {
 // Register the actions
 $this->registerBlogAction( "gallery", "PluginGalleryShowAction" );
 }


    function initAdmin()
    {

3.設定參數:

我的環境(以華龍國小教務處網誌為例):

  • lifetype 安裝在 /var/www/html/plog
  • Gallery2 安裝在 /var/www/html/gallery
  • 教務處網誌的blogId=3
  • 教務處的相簿在http://plog.hlps.tcc.edu.tw/gallery2/main.php/v/adm1/

設定gallery plugin 的參數 

* 

  • /var/www/html/gallery2/embed.php 

* 

  • /plog/index.php?op=gallery&blogId=3

*

  *

  • /gallery2/main.php

  圖片區塊:

  選擇下面的選項,加入你想要出現在網誌上相片的區塊,用 「|」來做區隔,加入一種選項,網誌上就會出現一張相片,加入兩種選項,就會出現兩張相片

randomImage(隨機圖片)|recentImage(最新圖片)|viewedImage(觀賞過的圖片)|randomAlbum(隨機相簿)|recentAlbum(最新相簿)|viewedAlbum(觀賞過的相簿)|specificItem(特定的相簿)dailyImage(本日圖片)|weeklyImage(本週圖片)|monthlyImage(本月圖片)|dailyAlbum(本日相簿)|weeklyAlbum(本週相簿)|monthlyAlbum(本月相簿)
  • randomAlbum|recentAlbum

 

  出現在相片下面的說明文字,一樣以「|」做區隔,若不輸入或輸入none,就是沒有說明文字。

  title(標題)|date(日期)|views(觀賞次數)|owner(擁有者)|heading(?)|fullSize(全尺寸的圖片)
  •   none

 

  這裡就是要輸入你想要顯示的相簿項目代碼,例如我們華龍電子相簿已改成簡短網址,教務處相簿的網址為
  http://plog.hlps.tcc.edu.tw/gallery2/main.php/v/adm1,我們要的就是main.php/v後面的東西,教務處相簿的一般網址為

  http://plog.hlps.tcc.edu.tw/gallery2/main.php?g2_view=core.ShowItem&g2_itemId=3214,這裡就要輸入「3214」

  •  /adm1

 4.修改模版:

 gallery plugin裡的裡README有說到

3. Add the following to your template so that it adds the link.
   {if $gallery->isEnabled()}
     <a title="My Photos" href="index.php?op=gallery">
      {$locale->tr("gallery")}
     </a>
   {/if}
4. Optionally add the following for image blocks
   {if $gallery->isEnabled()}{$gallery->getImageBlock()}{/if}

 

我在華龍教務處網誌的模版修改如下,結果如右圖所示

{if !empty($gallery)}
{if $gallery->isEnabled()}
<ul>
<h2>教務處相簿</h2>
<br>
<div align=center>
{$gallery->getImageBlock()}
<a title="教務處相簿" href="{$url->getBaseUrl()}/index.php?op=gallery">教務處相簿</a>
<a title="教務處相簿" href="{$url->getBaseUrl()}/index.php/v/adm1/?op=gallery">教務處相簿</a>
</div>
</ul>
{/if}
{/if}

07/20更新
上面原本的連結是會連到華龍電子相簿,而不是連到教務處相簿,因為我們教務處相簿是在
http://plog.hlps.tcc.edu.tw/gallery2/main.php/v/adm1/,所以必須再修改一下。
  •  {$gallery->getImageBlock()}

就是產生如右圖的兩張圖片,會有兩張,就是因為上面「  圖片區塊:」裡我設定為「randomAlbum|recentAlbum」的關係

  •  <a title="教務處相簿" href="{$url->getBaseUrl()}/index.php/v/adm1/?op=gallery">教務處相簿</a>

有沒有發現,這裡我的設定跟README 不太一樣,多了個 {$url->getBaseUrl()},這是為什麼呢?

忘了LT自哪一版後,在網誌的網址上,都會多出個/blog(我的LifeType是使用簡潔網址),所以我們若依照README的說明來做的話, 會發生錯誤,無法在網誌上呈現GAllery2連到相簿,所以我就手動加上{$url->getBaseUrl()},這個東西就是華龍部落格的網址(http://plog.hlps.tcc.edu.tw/plog),這樣就不會自動產生/blog這個了。

也就是說,若按照README來做,如右圖那個「教務處相簿」的連結就會變成

http://plog.hlps.tcc.edu.tw/plog/blog/index.php/v/adm1/?op=gallery

這樣會無法連結到教務處相簿。若加上{$url->getBaseUrl()},連結網址就會變成

http://plog.hlps.tcc.edu.tw/plog/index.php/v/adm1/?op=gallery ,這樣才能正確顯示。


完工!