您的位置:首页 > 运维架构 > 网站架构

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

2012-03-18 01:28 225 查看
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 语言实现的服务。

<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 中。

<simple-method method-name="getVisualThemeResources" 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: