原创作者: coldtear
阅读:7093次
评论:0条
更新时间:2011-05-26
Liferay Portal为我们提供了非常灵活的主题风格定制功能,自身带了四种风格的theme,在官方网站上提供了很多风格theme的下载,这无疑大大增强了主题风格定制的功能。但是,我们完全可以开发具有自己风格的theme,这里,我们将讨论怎样来开发个性的theme。
第一步:我们将以现有风格classic为模板文件创建新的theme,我们将新theme命名为coldtear
1、将liferay/html/themes目录下的classic文件夹copy一份副本,并修改副本的文件夹名为coldtea
2、在liferay/web-inf目录下新建liferay-look-and-feel-ext.xml文件,文件liferay-look-and-feel.xml是定义主题风格theme的配置文件,为了加以区分,我们在这里新建了该文件的扩展文件liferay-look-and-feel-ext.xml,该文件内容如下:
第二步、分析classic的主题布局的划分
1、打开liferay/html/theme/coldtear/templates目录,该目录下存放着很多jsp文件,打开portal_normal.jsp文件可以看到,该文件是整个页面的主体,通过 标签和<%@ include>方法包含了很多jsp文件,其中top.jsp文件定义了头部信息,navigation.jsp定义了导航菜单,bottom.jsp定义了底部语言标签信息,而页面的主体信息是由 标签定义的,top="portlet_top.jsp"定义了portlet的标题栏信息,bottom="portlet_bottom.jsp"定义了portlet下面的阴影线,portlet的内容则是由 定义的。所有的css样式信息是定义在css_cached.jsp文件中的。
2、liferay portal的页面定义大部分地方都采用了DIV+CSS的方式,下面将以classic的整个DIV定义框架给出,以说明classic风格的定义方法。
第一步:我们将以现有风格classic为模板文件创建新的theme,我们将新theme命名为coldtear
1、将liferay/html/themes目录下的classic文件夹copy一份副本,并修改副本的文件夹名为coldtea
2、在liferay/web-inf目录下新建liferay-look-and-feel-ext.xml文件,文件liferay-look-and-feel.xml是定义主题风格theme的配置文件,为了加以区分,我们在这里新建了该文件的扩展文件liferay-look-and-feel-ext.xml,该文件内容如下:
xml version="1.0"?>
<!--</span-->DOCTYPE look-and-feel PUBLIC "-//Liferay//DTD Look and Feel 4.0.0//EN" "http://www.liferay.com/dtd/liferay-look-and-feel_4_0_0.dtd">
<look-and-feel>
<compatibility>
<version>4.0.0<!--</span-->version>
<!--</span-->compatibility>
<company-limit>
<company-includes />
<company-excludes />
<!--</span-->company-limit>
<theme id="coldtear" name="ColdTear">
<root-path>/html/themes/coldtear<!--</span-->root-path>
<templates-path>/html/themes/coldtear/templates<!--</span-->templates-path>
<images-path>/html/themes/coldtear/images<!--</span-->images-path>
<template-extension>jsp<!--</span-->template-extension>
<color-scheme id="01" name="Blue">
<!--</span-->[CDATA[
body-bg=#FFFFFF
layout-bg=#FFFFFF
layout-text=#000000
layout-tab-bg=#E0E0E0
layout-tab-text=#000000
layout-tab-selected-bg=#6699CC
layout-tab-selected-text=#4A517D
portlet-title-bg=#6699CC
portlet-title-text=#4A517D
portlet-menu-bg=#B6CBEB
portlet-menu-text=#000000
portlet-bg=#FFFFFF
portlet-font=#000000
portlet-font-dim=#C4C4C4
portlet-msg-status=#000000
portlet-msg-info=#000000
portlet-msg-error=#FF0000
portlet-msg-alert=#FF0000
portlet-msg-success=#007F00
portlet-section-header=#094170
portlet-section-header-bg=#ADBDFB
portlet-section-subheader=#405278
portlet-section-subheader-bg=#91AEE8
portlet-section-body=#000000
portlet-section-body-bg=#E2E7FA
portlet-section-body-hover=#FFFFFF
portlet-section-body-hover-bg=#AC6CFA
portlet-section-alternate=#000000
portlet-section-alternate-bg=#CFD7FB
portlet-section-alternate-hover=#FFFFFF
portlet-section-alternate-hover-bg=#AC6CFA
portlet-section-selected=#7AA0EC
portlet-section-selected-bg=#FAFCFE
portlet-section-selected-hover=#00329A
portlet-section-selected-hover-bg=#C0D2F7
]]>
<!--</span-->color-scheme>
<!--</span-->theme>
<!--</span-->look-and-feel>
这里,注意的是修改theme的id和name,以及root-path、templates-path和images-path的路径,这样,我们就可以在主题风格页面看到我们新的theme了。<!--</span-->DOCTYPE look-and-feel PUBLIC "-//Liferay//DTD Look and Feel 4.0.0//EN" "http://www.liferay.com/dtd/liferay-look-and-feel_4_0_0.dtd">
<look-and-feel>
<compatibility>
<version>4.0.0<!--</span-->version>
<!--</span-->compatibility>
<company-limit>
<company-includes />
<company-excludes />
<!--</span-->company-limit>
<theme id="coldtear" name="ColdTear">
<root-path>/html/themes/coldtear<!--</span-->root-path>
<templates-path>/html/themes/coldtear/templates<!--</span-->templates-path>
<images-path>/html/themes/coldtear/images<!--</span-->images-path>
<template-extension>jsp<!--</span-->template-extension>
<color-scheme id="01" name="Blue">
<!--</span-->[CDATA[
body-bg=#FFFFFF
layout-bg=#FFFFFF
layout-text=#000000
layout-tab-bg=#E0E0E0
layout-tab-text=#000000
layout-tab-selected-bg=#6699CC
layout-tab-selected-text=#4A517D
portlet-title-bg=#6699CC
portlet-title-text=#4A517D
portlet-menu-bg=#B6CBEB
portlet-menu-text=#000000
portlet-bg=#FFFFFF
portlet-font=#000000
portlet-font-dim=#C4C4C4
portlet-msg-status=#000000
portlet-msg-info=#000000
portlet-msg-error=#FF0000
portlet-msg-alert=#FF0000
portlet-msg-success=#007F00
portlet-section-header=#094170
portlet-section-header-bg=#ADBDFB
portlet-section-subheader=#405278
portlet-section-subheader-bg=#91AEE8
portlet-section-body=#000000
portlet-section-body-bg=#E2E7FA
portlet-section-body-hover=#FFFFFF
portlet-section-body-hover-bg=#AC6CFA
portlet-section-alternate=#000000
portlet-section-alternate-bg=#CFD7FB
portlet-section-alternate-hover=#FFFFFF
portlet-section-alternate-hover-bg=#AC6CFA
portlet-section-selected=#7AA0EC
portlet-section-selected-bg=#FAFCFE
portlet-section-selected-hover=#00329A
portlet-section-selected-hover-bg=#C0D2F7
]]>
<!--</span-->color-scheme>
<!--</span-->theme>
<!--</span-->look-and-feel>
第二步、分析classic的主题布局的划分
1、打开liferay/html/theme/coldtear/templates目录,该目录下存放着很多jsp文件,打开portal_normal.jsp文件可以看到,该文件是整个页面的主体,通过 标签和<%@ include>方法包含了很多jsp文件,其中top.jsp文件定义了头部信息,navigation.jsp定义了导航菜单,bottom.jsp定义了底部语言标签信息,而页面的主体信息是由 标签定义的,top="portlet_top.jsp"定义了portlet的标题栏信息,bottom="portlet_bottom.jsp"定义了portlet下面的阴影线,portlet的内容则是由 定义的。所有的css样式信息是定义在css_cached.jsp文件中的。
2、liferay portal的页面定义大部分地方都采用了DIV+CSS的方式,下面将以classic的整个DIV定义框架给出,以说明classic风格的定义方法。
<div id="layout-outer-side-decoration">
<div id="layout-inner-side-decoration">
<div id="layout-box">
<!--</span><span style="COLOR: #000000"> 定义头部信息 top.jsp </span><span style="COLOR: #000000">-->
<div id="layout-top-banner">
<div id="layout-user-menu" style="text-align: right;">
<div class="font-small" style="margin-top: 5px;">
<div id="layout-my-places">
<div id="p_p_id_49_" class="portlet-boundary">
<div class="portlet-borderless-container">
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span><span style="COLOR: #000000"> 定义导航菜单 navigation.jsp </span><span style="COLOR: #000000">-->
<div id="layout-nav-container">
<div class="layout-nav-tabs-box">
<div class="layout-tab"><!--</span-->div>
<div class="layout-tab"><!--</span-->div>
<div class="layout-tab-selected"><!--</span-->div>
<div class="layout-tab"><!--</span-->div>
<!--</span-->div>
<div id="layout-global-search"><!--</span-->div>
<!--</span-->div>
<div class="portlet-bottom-decoration-2"><div><div><!--</span-->div><!--</span-->div><!--</span-->div>
<!--</span><span style="COLOR: #000000"> 定义主体portlet信息部分 </span><span style="COLOR: #000000">-->
<div id="layout-content-outer-decoration">
<div id="layout-content-inner-decoration">
<div id="layout-content-container">
<div id="layout-column_column-1">
<div id="p_p_id_73_INSTANCE_9Q28_" class="portlet-boundary">
<div class="portlet-container">
<!--</span><span style="COLOR: #000000"> 定义portlet标题栏信息 portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">top.jsp </span><span style="COLOR: #000000">-->
<div class="portlet-header-bar" id="portlet-header-bar_73_INSTANCE_9Q28" onmouseover="PortletHeaderBar.show(this.id)" onmouseout="PortletHeaderBar.hide(this.id)">
<div class="portlet-wrap-title">
<!--</span-->div>
<div class="portlet-small-icon-bar" style="display: none;">
<!--</span-->div>
<!--</span-->div>
<!--</span><span style="COLOR: #000000"> 定义portlet内容信息 </span><span style="COLOR: #000000">-->
<div class="portlet-box">
<div class="portlet-minimum-height">
<div id="p_p_body_73_INSTANCE_9Q28" >
<div class="slide-maximize-reference">
<div id="p_p_content_73_INSTANCE_9Q28_" style="margin-top: 0; margin-bottom: 0;">
<!--</span-->div>
<!--</span-->div><!--</span><span style="COLOR: #000000"> slide</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">maximize</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">reference </span><span style="COLOR: #000000">-->
<!--</span-->div>
<!--</span-->div>
<!--</span-->div><!--</span><span style="COLOR: #000000"> end portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">box </span><span style="COLOR: #000000">-->
<!--</span><span style="COLOR: #000000"> 定义portlet底部阴影线 portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bottom.jsp </span><span style="COLOR: #000000">-->
<div class="portlet-bottom-decoration-2"><div><div><!--</span-->div><!--</span-->div><!--</span-->div>
<!--</span-->div><!--</span><span style="COLOR: #000000"> End portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">container </span><span style="COLOR: #000000">-->
<!--</span-->div>
/Images/Ou
<div id="layout-inner-side-decoration">
<div id="layout-box">
<!--</span><span style="COLOR: #000000"> 定义头部信息 top.jsp </span><span style="COLOR: #000000">-->
<div id="layout-top-banner">
<div id="layout-user-menu" style="text-align: right;">
<div class="font-small" style="margin-top: 5px;">
<div id="layout-my-places">
<div id="p_p_id_49_" class="portlet-boundary">
<div class="portlet-borderless-container">
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span-->div>
<!--</span><span style="COLOR: #000000"> 定义导航菜单 navigation.jsp </span><span style="COLOR: #000000">-->
<div id="layout-nav-container">
<div class="layout-nav-tabs-box">
<div class="layout-tab"><!--</span-->div>
<div class="layout-tab"><!--</span-->div>
<div class="layout-tab-selected"><!--</span-->div>
<div class="layout-tab"><!--</span-->div>
<!--</span-->div>
<div id="layout-global-search"><!--</span-->div>
<!--</span-->div>
<div class="portlet-bottom-decoration-2"><div><div><!--</span-->div><!--</span-->div><!--</span-->div>
<!--</span><span style="COLOR: #000000"> 定义主体portlet信息部分 </span><span style="COLOR: #000000">-->
<div id="layout-content-outer-decoration">
<div id="layout-content-inner-decoration">
<div id="layout-content-container">
<div id="layout-column_column-1">
<div id="p_p_id_73_INSTANCE_9Q28_" class="portlet-boundary">
<div class="portlet-container">
<!--</span><span style="COLOR: #000000"> 定义portlet标题栏信息 portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">top.jsp </span><span style="COLOR: #000000">-->
<div class="portlet-header-bar" id="portlet-header-bar_73_INSTANCE_9Q28" onmouseover="PortletHeaderBar.show(this.id)" onmouseout="PortletHeaderBar.hide(this.id)">
<div class="portlet-wrap-title">
<!--</span-->div>
<div class="portlet-small-icon-bar" style="display: none;">
<!--</span-->div>
<!--</span-->div>
<!--</span><span style="COLOR: #000000"> 定义portlet内容信息 </span><span style="COLOR: #000000">-->
<div class="portlet-box">
<div class="portlet-minimum-height">
<div id="p_p_body_73_INSTANCE_9Q28" >
<div class="slide-maximize-reference">
<div id="p_p_content_73_INSTANCE_9Q28_" style="margin-top: 0; margin-bottom: 0;">
<!--</span-->div>
<!--</span-->div><!--</span><span style="COLOR: #000000"> slide</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">maximize</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">reference </span><span style="COLOR: #000000">-->
<!--</span-->div>
<!--</span-->div>
<!--</span-->div><!--</span><span style="COLOR: #000000"> end portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">box </span><span style="COLOR: #000000">-->
<!--</span><span style="COLOR: #000000"> 定义portlet底部阴影线 portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bottom.jsp </span><span style="COLOR: #000000">-->
<div class="portlet-bottom-decoration-2"><div><div><!--</span-->div><!--</span-->div><!--</span-->div>
<!--</span-->div><!--</span><span style="COLOR: #000000"> End portlet</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">container </span><span style="COLOR: #000000">-->
<!--</span-->div>
/Images/Ou
评论 共 0 条 请登录后发表评论