OFBIZ 网站或店铺视觉主题(visual Theme)设计

what   why


v.在ofbiz中的应用的主题是可以通过数据来配置的,在webtools 组件中的catalog,  content 菜单下可分别设置店铺和网站的主题。且ofbiz在设计前端页面时,不使用table之类的html元素进行布局,而是大量使用div元素进行布局。 这样可以为一个网站或店铺设置多种不同的视觉风格,同时做到html中内容和风格的分离,提高开发效率及可维护性。

how

v.在ofbiz 中的ecommerce 示例中网站的主题是根据一个action 中的 service 的得到的。 而这个Service 使用mini 语言实现的。

在Ecommerce 下的CommonScreens.xml#main-decorator   action 中通过service 标签调用 mini 语言实现的服务。
</pre><pre name="code" class="html"><script location="component://ecommerce/widget/EcommerceSetup.groovy"/>    
<!-- Get the store VisualTheme -->    
<set field="visualThemeId" from-field="productStore.visualThemeId" default-value="EC_DEFAULT"/>    
<SPAN style="COLOR: #ff0000">  
    <service service-name="getVisualThemeResources">  
</SPAN>    
<field-map field-name="visualThemeId"/>    
<field-map field-name="themeResources" from-field="layoutSettings"/>    
</service>    
<set field="layoutSettings" from-field="themeResources" default-value="${layoutSettings}" global="true"/>    
<set field="headerTemplateLocation" from-field="layoutSettings.VT_HDR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/header.ftl"/>    
<set field="footerTemplateLocation" from-field="layoutSettings.VT_FTR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/footer.ftl"/>    
  
<script location="component://ecommerce/widget/EcommerceSetup.groovy"/>  
  
<!-- Get the store VisualTheme -->  
<set field="visualThemeId" from-field="productStore.visualThemeId" default-value="EC_DEFAULT"/>  
<service service-name="getVisualThemeResources">  
    <field-map field-name="visualThemeId"/>  
    <field-map field-name="themeResources" from-field="layoutSettings"/>  
</service>  
<set field="layoutSettings" from-field="themeResources" default-value="${layoutSettings}" global="true"/>  
<set field="headerTemplateLocation" from-field="layoutSettings.VT_HDR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/header.ftl"/>  
<set field="footerTemplateLocation" from-field="layoutSettings.VT_FTR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/footer.ftl"/>  

mini 语言实现的服务在ofbiz\framework\common\script\org\ofbiz\common\CommonServices.xml 中。

<span style="font-family:楷体;"><strong><simple-method method-name="<SPAN style="COLOR: #ff6600">getVisualThemeResources</SPAN>" short-description="Get visual theme resources" login-required="false">    
       <set field="visualThemeId" from-field="parameters.visualThemeId"/>    
       <set field="themeResources" from-field="parameters.themeResources"/>    
       <entity-condition list="resourceList" entity-name="VisualThemeResource" use-cache="true">    
           <condition-expr field-name="visualThemeId" from-field="visualThemeId"/>    
           <order-by field-name="resourceTypeEnumId"/>    
           <order-by field-name="sequenceId"/>    
       </entity-condition>    
       <if-empty field="resourceList">    
           <!-- if not found use the good old initial ofbiz theme so the system will at least start up and will be usable -->    
           <log level="error" message="Could not find the '${visualThemeId}' theme, reverting back to the good old OFBiz theme..."></log>    
           <entity-condition list="resourceList" entity-name="VisualThemeResource" use-cache="true">    
               <condition-expr field-name="visualThemeId" value="FLAT_GREY"/>    
               <order-by field-name="resourceTypeEnumId"/>    
               <order-by field-name="sequenceId"/>    
           </entity-condition>    
       </if-empty>    
       <if-empty field="resourceList">    
           <add-error><fail-property property="CommonVisualThemeResourcesNotFound" resource="CommonUiLabels"/></add-error>    
           <check-errors/>    
       </if-empty>    
       <iterate list="resourceList" entry="resourceRecord">    
           <set field="resourceTypeEnumId" from-field="resourceRecord.resourceTypeEnumId"/>    
           <set field="resourceValue" from-field="resourceRecord.resourceValue"/>    
           <if-empty field="resourceValue">    
               <property-to-field field="warningMsg" property="CommonVisualThemeInvalidRecord" resource="CommonUiLabels"/>    
               <log level="warning" message="${warningMsg}"/>    
               <else>    
                   <set field="themeResources[resourceTypeEnumId][]" from-field="resourceValue"/>    
               </else>    
           </if-empty>    
       </iterate>    
       <field-to-result field="themeResources"/>    
   </simple-method>    </strong></span>




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值