今天必須在Liferay 控制台新增一個客製欄位,讓theme去抓取其中的值並以跑馬燈顯示;

 

首先必須要到控制台的custom fields裡,site的分類底下去新增所需要的客製欄位;

客製欄位1  

 

其中的key值就是等等要抓取資料用的索引,在這裡是marqueeInput。

完成之後site setting 的custom fields裡就會出現剛剛定義的客製欄位如下圖。

客製欄位2  

接著就可以在theme客製的.vm檔案裡去抓取所輸入的資料,在這裡用的語言跟在template裡用的一樣,日後還需繼續鑽研;

 

#set ($site_shortname = $themeDisplay.getScopeGroup().getExpandoBridge().getAttribute("marqueeInput"))

以上是將所獲得的參數指定給site_shortname,因為是在site裡,

在這裡用$themeDisplay.getScopeGroup().getExpandoBridge().getAttribute("marqueeInput")的方式抓取。

 


<marquee direction="left" scrollamount="3"

style="padding: 5px; margin: 0;"> <span style="padding-right:100px;">

$site_shortname</span>

</marquee>

以上就是把跑馬燈要顯示的資料指定為$site_shortname,

 

完成之後掛上該theme插件,就可以有一個自定義的跑馬燈;

客製欄位3  

 

可參考:

http://stackoverflow.com/questions/9827968/how-to-access-custom-fields-of-a-page-in-the-theme-template

 

https://www.liferay.com/community/forums/-/message_boards/message/20669628

 

http://www.liferaysavvy.com/2014/02/introduction-to-liferay-custom.html

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 squall75726 的頭像
    squall75726

    菜鳥工程師的Liferay Portal學習筆記

    squall75726 發表在 痞客邦 留言(0) 人氣()