magento设计人员中文手册

来源:互联网 发布:域名注册的网站有哪些 编辑:程序博客网 时间:2024/05/02 00:08

基本概念


website(站点)和store(商店)
magento中的website和store是泛指的概念。website被认为是一组store的集合,而store则是一组store view(商店视图)的集合。这两个概念的定义甚至可以根据需要来定义。

interface(界面)
magento中的interface是一组theme的集合。一个interface可以被应用到整个website也可以应用到某个
特定的store。如果interface被应用到了website,那么该website下的所有store都将使用同一风格的interface,如果是被应用到store,那么这个store就采用它自己的store,也就是说store的设置覆盖掉website的设置。


theme(主题)

magento中的theme是指layout(布局),template(模板),locale(区域语言)和skin(皮肤)文件的总和。magento一次可以载入多个theme,所以主题就分成两大类default(默认) theme和non-default(非默认) theme。

Default theme
每一个interface都会包含有一个default theme。当你指定站点(website)或商店(store)使用某个interface时,这个interface的default theme会被自动加载。如果你需要修改设计,你可以直接修改default theme,也可以创建一个non-default theme,并在这个新建的non-default theme中做你需要做的修改。之所以这样做你的修改会生效是因为magento可以同时加载多个theme,而且default theme总是具有最低的优先级。也正因为如此,default theme需要包含所有的必须的layout,templates和skins文件,而non-default theme则只需要包含我们需要修改的文件,当然也可以包含所有的相关文件。

Non-default theme
non-default theme可以包含任意多的文件,也可以只包含我们所需要的那一点文件,因为default theme会提供fallback给其它的所有需要的文件。通常non-default theme是提供季节性的或促销性的主题,一般只是修改一些CSS文件,或者替换掉一些图片什么的。


Layout
保存在app/design/frontend/your_interface/your_theme/layout/目录中,是一组XML文件,用来定义各个页面的block结构和META信息。

Templates
保存在app/design/frontend/your_interface/your_theme/template/目录中,是一组phtml文件,包含普通的xhtml代码和php代码。

Locale
保存在app/design/frontend/your_interface/your_theme/locale/目录中的一组文档,用来提供翻译信息。

Skins
保存在skin/frontend/your_interface/your_theme/目录中的js,css,image文件



Blocks
magento是以block为单位来提供功能的。分成以下两在类型:
结构block
这种block主要是用于指定可视的页面结构到页面。比如页面顶部,左边栏目,底部,
它本身不包含内容,事实上则是一个内容容器。通过这样一个个结构block组成了一个页面。



内容block
这种block用来向结构block输出真实的内容。事实上就是页面上提供的各种功能,比如搜索框,
目录列表,迷你购物车,产品标签...


magento正是通过结构block(结合layout)编排好页面,然后通过内容block输(结合layout)出内容。

有了上面的基本概念的初步认识,我们下面通过实例来加深学习。

为新interface创建一个default theme

Directory 1: app/design/frontend/default/default/ — This directory contains the layout, translation (locale) and template materials.
Directory 2: skin/frontend/default/default/ — This directory contains the images, CSS and block-specific Javascripts.

分别从上面的两个目录复制到下面这两个目录

Directory 1: app/design/frontend/new_interface/default/
Directory 2: skin/frontend/new_interface/default/
注:new_interface为新interface名称,default是default theme的名称
这样就相当于创建了一个新的new_interface interface,并且为它创建了一个default theme..

创建一个non-default theme

在创建一个non-default theme,我们不需要复制整个default theme的文件目录(当然你要是这么做也是可以的),我们只需要将我们要修改的文件复制过来,并在此基础上做修改。有一点需要注意的是,在复制文件时,不仅要复制文件本身,还要让文件在新的theme中和在default theme中有一样的目录结构,也就是
它的父目录一直上溯到theme这层要保持一致。比如你要修改的是:app/design/frontend/default/default/template/catalog/home.phtml那么你需要创建一个这样的文件app/design/frontend/your_interface/your_non_default_theme/template/catalog/home.phtml

 

(待续...)