posts - 19,  comments - 123,  trackbacks - 0
          ?????? Liferay Portal 4.0 為我們提供了幾種不同的頁面布局,我們可以通過 Add Content 中的 Template 參數來指定不同的頁面布局,但是,但我們利用 CMS 來定制文章內容的時候,僅有的幾種頁面布局并不能滿足我們的需求,所以我們需要開發能夠滿足特定需求的頁面布局。
          ??? 我們將開發一個具有下圖風格的頁面布局,該布局中我們指定了7個區域來分別裝配portlet實現獨特的頁面風格。
          1.JPG
          一、編寫模板文件
          ??? 我們將該頁面風格名稱定義為1_2_3_2 Columns,在Liferay/html/layouttpl/custom目錄下新建1_2_3_2_columns.tpl文件,內容如下:
          <div?id="layout-content-outer-decoration">
          <div?id="layout-content-inner-decoration">
          ????
          <div?id="layout-content-container">
          ??????
          <table?border="0"?cellpadding="0"?cellspacing="0"?width="100%">
          ????????
          <tr>
          ??????????
          <td?colspan="3"?valign="top">
          ????????????$processor.processColumn(
          "column-1")
          ??????????
          </td>
          ????????
          </tr>
          ????????
          <tr>
          ??????????
          <td?width="79%"?valign="top">
          ??????????????
          <table?border="0"?cellpadding="0"?cellspacing="0"?width="100%">
          ????????????????
          <tr>
          ????????????????
          <td?width="26%"?valign="top">
          ??????????????????$processor.processColumn(
          "column-2")
          ????????????????
          </td>
          <td?class="layout-column-spacer"?width="1%">
          ????????????????????
          <div>&nbsp;</div>
          ??????????????????
          </td>
          ????????????????
          <td?width="26%"?valign="top">
          ??????????????????$processor.processColumn(
          "column-3")
          ????????????????
          </td>
          ??????????????????
          <td?class="layout-column-spacer"?width="1%">
          ????????????????????
          <div>&nbsp;</div>
          ??????????????????
          </td>
          ????????????????
          <td?width="26%"?valign="top">
          ??????????????????$processor.processColumn(
          "column-4")
          ????????????????
          </td>
          ????????????????
          </tr>
          ??????????????
          </table>
          ????????????
          </td>
          ??????????
          <td?class="layout-column-spacer"?width="1%">
          ????????????
          <div>&nbsp;</div>
          ??????????
          </td>
          ??????????
          <td?width="20%"?rowspan="2"?valign="top">
          ????????????$processor.processColumn(
          "column-5")
          ??????????
          </td>
          ????????
          </tr>
          ????????
          <tr>
          ??????????
          <td?colspan="2">
          ????????????
          <table?border="0"?cellpadding="0"?cellspacing="0"?width="100%">
          ??????????????
          <tr>
          ????????????????
          <td?width="50%"?valign="top">
          ??????????????????$processor.processColumn(
          "column-6")
          ????????????????
          </td>
          ????????????????
          <td?width="50%"?valign="top">
          ??????????????????$processor.processColumn(
          "column-7")
          ????????????????
          </td>
          ??????????????
          </tr>
          ????????????
          </table>
          ????????????
          </td>
          ????????
          </tr>
          ??????
          </table>
          ????
          </div>
          </div>
          </div>

          ??? 文件中前三行定義的 <div> 和最后三行 </div> 是固定的模板格式,從第四行開始就是我們需要定制的頁面風格的 HTML 格式,我們需要將輸出 portlet 區域的 HTML 語句用 $processor.processColumn("column-1") 來替換,“ column-1 ”是該區域的名稱,并且每個區域的名字不能重復,這樣系統在生成模板的時候會自動生成不同的區域來存放我們指定的 portlet

          二、編寫屬性文件

          ??? 我們需要在 liferay-layout-templates.xml 文件中配置我們自定義的頁面布局文件 1_2_3_2_columns.tpl ,為了和系統自帶的布局文件區分開,我們創建擴展文件 liferay-layout-templates-ext.xml ,在該文件中指定我們的頁面布局文件,當然也可以在 liferay-layout-templates.xml 文件直接增加定義。

          ?

          liferay-layout-templates-ext.xml

          <? xml?version = " 1.0 " ?>
          <! DOCTYPE?layout - templates?PUBLIC? " -//Liferay//DTD?Layout?Templates?4.0.0//EN " ? " http://www.liferay.com/dtd/liferay-layout-templates_4_0_0.dtd " >

          < layout - templates >
          ????
          < custom >
          ????????
          < layout - template?id = " 1_2_3_2_columns " ?name = " 1-2-3-2?Columns " >
          ????????????
          < template - path >/ html / layouttpl / custom / 1_2_3_2_columns.tpl </ template - path >
          ????????
          </ layout - template >
          ????
          </ custom >
          </ layout - templates >

          參數 id 定義該 template ID 號, name 定義該 template Add Content 中顯示的名稱, template-path 定義該 template 的路徑名。


          三、定制頁面
          ????定制好頁面風格后,需要重新啟動TOMCAT,登陸系統,進入GUEST頻道,點擊Add Content ,在Template中將會顯示我們自定義的頁面布局名稱1-2-3-2 Columns,選擇該Template,然后在頁面中添加Journal Content,按照我們自定義的布局將portlet拖拉到合適的位置,再為每個Journal Content指定Article,最后就完成了各種風格頁面的定制過程。使用這個的方法,我們可以定制各種滿足不同需求的頁面。

          posted on 2006-08-04 18:02 韓淚 閱讀(4385) 評論(10)  編輯  收藏 所屬分類: Liferay學習


          FeedBack:
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-07 13:49 | robertpi
          不錯,不錯,希望繼續寫下去.  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-07 17:16 | 韓淚
          非常感謝您的支持,我一定堅持下去  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-17 13:47 | trevol
          樓主加油!  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-18 13:38 | chu xue zhe
          謝謝摟主,但是我的這個上邊為什么沒有配置自定義模板屬性的文件呢?怎樣找到???  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-18 13:40 | chu xue zhe
          在哪里找“我們需要在 liferay-layout-templates.xml 文件中配置我們自定義的頁面布局文件 1_2_3_2_columns.tpl ”?  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-18 14:40 | 韓淚
          @chu xue zhe
          頁面布局文件 1_2_3_2_columns.tpl 這個文件是我們自己定義的,用來定義你自己的布局風格  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-18 15:21 | chu xue zhe
          終于找到了,摟主理解錯我的一次了。我的版本跟你的不一樣,這個是剛下載的,4.0版本。在C:\liferay-portal-tomcat\webapps\ROOT\WEB-INF里面。謝謝!  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2006-08-21 10:21 | Spike Wang
          謝謝希望相互交流

          我也是liferay 愛好者,希望相互勉勵。

          我的MSN : hk2000c@hotmail.com

            回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template
          2007-04-09 17:33 | ericLiu
          謝謝~你的文章寫的很詳細~~,很感謝你的共享  回復  更多評論
            
          # re: 【原創】Liferay Portal學習筆記(三):自定義頁面布局Template[未登錄]
          2007-09-29 16:38 | Bruce
          我想問一下,為什么我的按上面的操作,布局6和7沒有出現?  回復  更多評論
            

          虛其心,可解天下之問; 專其心,可治天下之學; 靜其心,可悟天下之理; 恒其心,可成天下之業。

          常用鏈接

          留言簿(12)

          隨筆分類(19)

          隨筆檔案(19)

          搜索

          •  

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 龙南县| 鞍山市| 泸水县| 大宁县| 沐川县| 内黄县| 安仁县| 天柱县| 临沧市| 独山县| 中山市| 平阴县| 霸州市| 临潭县| 虞城县| 承德市| 田林县| 辽宁省| 揭西县| 张家港市| 离岛区| 肥城市| 察雅县| 五常市| 湛江市| 葵青区| 镇江市| 崇义县| 长沙市| 马龙县| 民丰县| 城固县| 张家口市| 海安县| 和龙市| 绥芬河市| 孟津县| 黄梅县| 丰镇市| 永胜县| 桂东县|