Lightbox

| 二月 28, 2006 | 6個迴響| 沒有引用| 2843 reads | Size: L, M, S | Edit: P, C, R |
| Category: LifeType. |

    之前就看到有人在 Lifetype 的中文論壇問這個東西,不過都一直沒有空玩。

    最近有人已經把他弄出來了,哈,感謝。紀錄一下。 

    參考這幾個地方:LightboxP's Lifetype華龍國小Lifetype學習網

    首先,先看一下甚麼是 Lightbox,點下方圖片看效果:

    Flickr_Card

    是的,是不是很炫?! 下面就來紀錄一下怎麼弄的。 

     

    1. 點 這裡下載 我改過的版本。

    2. 在 Lifetype 目錄下解壓縮這個壓縮檔,也就是五個檔案放在 /Lifetype-Root/lightbox/ 下面。

    3. 將 lightbox.js 及 lightbox.css 內的路經修改成你的站台的路徑。

    4. 由於要顯示出效果,圖片連結需要加上 rel="lightbox",如果願意每次都用 HTML 模式改就慢慢改吧。

     

    5. 如果懶得每次都改。以 TinyMCE 為例,可以修改 /js/tinymce/jscripts/tiny_mce/tiny_mce-plog-resourcelist.js 這個檔案。

    找到第22行左右,加上紅色粗體字部份:

    function _generateResourceLink( dest, blogId, type, resourceName, resourceDesc, preview, mimeType, resId )
    {
        var htmlCode = '';
        if( type == 1 ) {
            // if the resource is an image, check the second parameter to see wether we'd like
            // to show the preview with a link to the real size image or the real image
            // inlined with the text
            if( preview == 1 ) {
                htmlCode = '<a rel="lightbox" id="res_' + resId+ '" xhref="'+plogBaseUrl+'/resserver.php?blogId='+blogId+'&amp;resource='+encodeURIComponent(resourceName)+'" type="'+mimeType+'">';
                htmlCode += '<img style="margin: 5px;" border="0" alt="'+resourceDesc+'" xsrc="'+plogBaseUrl+'/resserver.php?blogId='+blogId+'&amp;resource='+encodeURIComponent(resourceName)+'&amp;mode=preview" />';
                htmlCode += '</a>';
            }
            else if ( preview == 2 ) {
                htmlCode = '<a rel="lightbox" id="res_' + resId+ '" xhref="'+plogBaseUrl+'/resserver.php?blogId='+blogId+'&amp;resource='+encodeURIComponent(resourceName)+'" type="'+mimeType+'">';
                htmlCode += '<img style="margin: 5px;" border="0" alt="'+resourceDesc+'" xsrc="'+plogBaseUrl+'/resserver.php?blogId='+blogId+'&amp;resource='+encodeURIComponent(resourceName)+'&amp;mode=medium" />';
                htmlCode += '</a>';
            }

    如此一來,加上圖片的時候,就會自動加上 rel="lightbox" 的語法了。

     

    6. 接著修改 /js/tinymce/jscripts/tiny_mce/tiny_mce-plog.js 這個檔案。

    找到19行左右,加上紅色粗體字部份:

    extended_valid_elements : "a[class|name|href|target|title|onclick|rel

     

    7. 最後,只要各自在模板的 header.template 檔案內 <head> 和 </head> 中間找個地方放入語法即可:

    <link rel="stylesheet" xhref="{$url->getUrl("/lightbox/lightbox.css")}" type="text/css" media="screen" />
    <script xsrc="{$url->getUrl("/lightbox/lightbox.js")}" type="text/javascript"></script>

     

    8. 在插入圖片的時候,請選擇中或小的預覽圖。這樣點下去就會有 lightbox 的效果。

     

    本站的使用者,只需要將上面 第7點 語法放入模板中即可 直接插入預覽小圖即可,我已經把相對應的修改弄好了。

     



    推薦文章:
    +FunP | +HEMiDEMi | +My Share | +TwitThat | +Del.icio.us
    隨機文章:
    » 修改模板
    » RSS - 全文顯示 或 限制內容
    » [Lifetype] TinyMCE 的 Hack
    近期文章:
    « 廠商誠信
    » 擋掉百度

Leave A Comment:













   



6 迴響 of "Lightbox"

lss By lss @ 2006 三月 01, 11:03 :

阿駕:
專心準備研究所啦,考完了再來玩,要乖。

steven謝謝分享 By steven @ 2006 三月 02, 08:10 :

你的內的語法寫的很讚!看過幾個教學網站,就是你的寫的最好!

不過
getUrl("/lightbox/lightbox.css")}" type="text/css" media="screen" />
getUrl("/lightbox/lightbox.js")}" type="text/javascript">

這當中xhref 跟 xscr 好像不能用在我的網站,我把x去掉就可以了。

ajer001 By ajer001 @ 2006 三月 03, 16:35 :

呵呵,只是分享、紀錄我的經驗而已。
很高興可以幫到你。

mousonRe:Lightbox By mouson @ 2007 四月 24, 16:33 :

阿駕,
剛突然發現,
可能是因為您的LT升級到1.2版,
所以LightBox的效果已經失效了喔!!

ajer001Re:Lightbox By ajer001 @ 2007 四月 24, 16:59 :

要看新舊文章,新的文章大都把圖丟到 Flickr 去了,所以就沒有加上去。 舊的文章,真的是失效了,還在找原因XD 還有一些零零碎碎的問題要解決、還有主機調校的事情,煩啊!

ajer001Re:Lightbox By ajer001 @ 2007 四月 24, 17:08 :

現在才發現你架站了,恭喜脫離魔掌啊!