




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
布局介绍Intro to Layouts星期二, 08/19/2008 - 22:22 foolsky 布局介绍Layouts布局Layout,就像它的的组件一样,很容易误导你以为要用好它就要先学习好编程逻辑。事实上,布局只是一些XML标签组成的。它很容易学习。学习一些关于布局的基本概念和命令之后,你会很自信的按你的意愿修改和设计你自己的网店布局 布局是如何工作的How Layout Works 解剖布局Anatomy of Layout XML规则Rules of XML 入门联系Quick Exercises to Get You Started 布局是如何工作的How Layout WorksLayout 布局是magento应用的一些虚拟组件。你可以通过修改这些布局组件来达到建设网店页面的目的。Diagram 1布局包含默认布局default layout和升级布局 layout updates两种,他们都是由很容易学习的XML标签构成的。通过这些布局命令,你可以修改/分配内容区块,结构区块的关系,也可以控制网店前台的功能性。比如加载或者卸载特定的区块JAVASCRIPTS到一个特定页面。布局文件是基于每个模块单独存放的。每个模块都有自己的布局文件。 (比如 catalog.xml 是catalog module的布局文件,.etc). 这些布局文件位于 app/design/frontend/your_interface/your_theme/layout/ and each file is further separated by handles (see diagram 1), each handle (with the exception of ) assigning its nested updates to the according specific page in the store.Some layout files may contain the handle. When parsing the layout files, Magento first grabs the layout updates assigned in the handle of almost all layout files, reading them in the order as assigned in app/etc/modules/Mage_All.xml. It then parses the page-specific layout update, finalizing the building of a store page.The system is built this way in order to allow seamless addition and removal of modules without effecting other modules in the system.Back to TopAnatomy of LayoutLayout contain a small set of XML tags that act as detailed instructions to the application on how to build a page, what to build it with and the behavior of each building block. The best way to approach layout is to just dive right in and attack it from all angles. In order for you to do that, herere some behavioral properties of each layout XML tag.HandleHandle (diagram 1) is an identifier by which the application determines what to do with the updates nested by it.If the name of the handle is , then the application knows that its nested updates must be loaded on almost all the pages of the store prior to loading page-specific layout (We say almost all, because some exceptional pages like the product image popup does not load the layout in the handle).If Magento finds handles other than , it will assign the updates nested inside the handle to the according page specified by the handle. For instance, contain the layout updates for the Product View page, while contain those for the Compare Product page. Handles are set-in-stone identifiers that as a designer with no extensive understanding of Magento programming, should never need to modify.Magento determines the behavior and visual representation of each building block of a page via the tag. Weve already mentioned the two types of blocks Magento employs - structural blocks and content blocks. The best way to distinguish between the two is by examining the behavior assigned to it via the tag attributes. A structural block usually contains the attribute as, through which the application is able to communicate with the designated area (by the getChildHtml method) in a template. You will notice many occurances of this as attribute in the default layout, because by nature the default layout is one that builds the ground work upon which the page-specific layouts can begin adding onto. For instance, in the default layout, therere structural blocks such as left, right, content and footer being introduced. Not to say these blocks cannot exist in normal layout updates, but why not first set up the reoccurring structural blocks in the default layout first, then start adding content on a per-page basis? Lets dig further into available attributes for . type This is the identifier of the module class that defines the functionality of the block. This attribute must not be modified. name This is the name by which other blocks can make reference to the block in which this attribute is assigned (see diagram 3). before (and) after These are two ways to position a content block within a structural block. before=- and after=- are commands used to position the block accordingly at the very top or very bottom of a structural block. template - This attribute determines the template that will represent the functionality of the block in which this attribute is assigned. For instance, if this attributes is assigned catalog/category/view.phtml, the application will load the app/design/frontend/template/catalog/category/view.phtml template file.In order to learn about how layout works with templates to bring markup to your store, read Step by Step Guide to Building a Theme action is used to control store-front functionalities such as loading or unloading of a Javascript. A full list of action methods will soon become available, but in the mean time the best way to learn about the different action methods is by playing around with them in the currently available layout updates. as This is the name by which a template calls the block in which this attribute is assigned. When you see the getChildHtml(block_name) PHP method called from a template, you can be sure it is referring to the block whose attribute as is assigned the name block_name. (ie. The method getChildHtml(header)? in the a skeleton template correlates to ) Diagram 3 is used to make reference to another block. By making a reference to another block, the updates inside will apply to the it correlates to (see diagram 3).In order to make the reference, you must target the reference to a block by using the name attribute. This attribute targets the tags name attribute. So if you were to make a reference by , youre targeting the block called .Back to TopRules of XMLDiagram 4If youre not familiar with it, upon encountering Magentos XML-based layout updates, you may have a question or two about the rules you must follow when modifying an XML file.The only set rule you need to remember with regards to XML, is that when a tag opens, it must either be followed by a closing tag() or self-close() exactly as (X)HTML file tags would.Back to TopQuick Exercises to Get You StartedJust like any new concepts, we know that without actually diving in and getting your hand dirty, you can never truly grasp what youve been explained in words. So here are a couple of exercises for you to get a feel for working with layouts. In order to work with this exercise, you must have the default Magento theme ready and accessible.Exercise #1: In the category page, move the My Cart box from the right column to the left1. Turn on the Template Path Hint by going to the admin then navigating to System - Configuration. When youre in the configuration page, select the store youre working in by using the top left website/store selector. Wait for the page to reload, then select the Developer tab. Select Yes in the select box for Template Path Hints. Click on Save. Go back to the store front, and reload. 2. When the page reloads, look at the template path of the My Cart block- itll most likely say frontend/default/default/template/checkout/cart/sidebar.phtml. By looking at the path, you know this template is being introduced via the checkout module. How do you know this? - frontend/default/default/template/checkout/cart/sidebar.phtml. It says so in the template path. The immediate directory name following template is the name of the module through which a template is introduced. 3. Open up layout/checkout.xml - because now we know were dealing with the checkout module 4. Search for checkout/cart/sidebar.phtml (the template name of the My Cart block) in the layout updates. You will find an area that looks like this: Change it to say the following instead (Note that all youre doing is changing the to ). 5. Reload the store front and you will now see the change reflected. Exercise #2: Separate the SEO links at the footer area - Instead of having the link items to be one list, isolate Advanced Search to be in the header instead.1. You can make a calculated assumption that the SEO links must be assigned somewhere in the layout under the footer block because its being pulled through getChildHtml()? of template/page/html/footer.phtml. (You will need the Template Path Hints turned on to see why this is obvious). 2. Open up layout/page.xml and look through the list of children under the footer block in order to locate a block that calls the footer links - You will find , which is what calls the SEO links. Now that you know that layout updates reference the SEO links via the name=footer_links, now you will do a search in all the xml files for . You will find references for the footer_links block in catalog.xml (which calls Site Map), catalogsearch.xml(which calls Search Terms and Advanced Search) and contacts.xml (which calls Contact Us). 3. Now that youve located the area of the individual SEO link items, you will now begin the steps to isolate Advanced S
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高标准厂房租赁安全生产及环境保护管理协议
- 餐饮公司股东投资收益分配合同
- 拆除工程安全责任及补偿协议范本
- 车辆租赁平台佣金分成合同
- 互联网教育代理记帐与课程资源整合合同
- 资源开发项目参股合作协议范本
- 产权拍卖合同范本
- 餐饮店拆伙退伙协议书(合同解除原因)
- 美食街特色餐饮摊位租赁及食品安全保障合同
- 特种矿产资源采矿权出让与科研开发合同
- 肾上腺疾病讲课件
- 四年级语文下册阅读专项归类复习(有答案)
- 颈椎肿瘤的护理
- 2025至2030中国不锈钢精密带材行业前景预测及发展趋势预判报告
- 无人机驾驶员雇佣合同协议
- 湖南省长沙市华益中学2023-2024学年八年级下学期期末考试英语试卷(含答案)
- (高清版)DB13∕T 2937-2019 非煤矿山双重预防机制建设规范
- 电动船舶生产线项目可行性研究报告(范文参考)
- 浙江宁波历年中考作文题与审题指导(2007-2021)
- 大学生医学健康科普演讲
- 2025国开电大《管理英语1》综合测试形考任务答案
评论
0/150
提交评论