Designing for Magento



Similar documents
Creating a new theme. Table of Contents

HOW TO CREATE THEME IN MAGENTO 2

Interspire Website Publisher Developer Documentation. Template Customization Guide

MAGENTO TRAINING PROGRAM

Improved Navigation Magento Extension User Guide

Fortis Theme. User Guide. v Magento theme by Infortis. Copyright 2012 Infortis

X-POS GUIDE. v3.4 INSTALLATION SmartOSC and X-POS

Magento Theme EM0006 for Computer store

ProxiBlue Gift Promotions

Magento 1.3: PHP Developer's Guide

FORTIS. User Guide. Fully responsive flexible Magento theme by Infortis. Copyright Infortis. All rights reserved

MAGENTO THEME SHOE STORE

Bazaarvoice for Magento Extension Implementation Guide v6.3.4

ultimo theme Update Guide Copyright Infortis All rights reserved

SEO Toolkit Magento Extension User Guide Official extension page: SEO Toolkit

J2T Points & Rewards Magento Extension

Using an external style sheet with Dreamweaver (CS6)

Magento 1.3 Theme Design

Testking.M Q

CREATE A CUSTOM THEME WEBSPHERE PORTAL

Using Style Sheets for Consistency

Website Planning Checklist

Using your Drupal Website Book 1 - Drupal Basics

Quick Start Guide. This guide will help you get started with Kentico CMS for ASP.NET. It answers these questions:

The Ultimate Magento

PDG Software. Site Design Guide

Magento Theme Instruction

Shop by Manufacturer Custom Module for Magento

Mastering Magento Theme Design

Building A Very Simple Web Site

Learning Magento Theme Development

SAHARA DIGITAL8 RESPONSIVE MAGENTO THEME

Hitachi PaybyFinance Magento Plugin

This guide provides additional information about topics covered in the webinar

Official Amazon Checkout Extension for Magento Commerce. Documentation

UH CMS Basics. Cascade CMS Basics Class. UH CMS Basics Updated: June,2011! Page 1

Magento Theme Instruction

JOOMLA 2.5 MANUAL WEBSITEDESIGN.CO.ZA

A set-up guide and general information to help you get the most out of your new theme.

Multivendor Extension User Guide

Software User Guide. WordPress Plugin Version 1.0

Configuring the JEvents Component

Shop Manager Manual ConfigBox 3.0 for Magento

The Ultimate Guide to Magento SEO Part 1: Basic website setup

E-commerce. Further Development 85

62 Ecommerce Search Engine Optimization Tips & Ideas

Outline of CSS: Cascading Style Sheets

(These instructions are only meant to get you started. They do not include advanced features.)

JISIS and Web Technologies

4 The Product Catalog Module

Website Search Engine Optimization (SEO) Evaluation XXXXXXX

Developers Guide. Designs and Layouts HOW TO IMPLEMENT WEBSITE DESIGNS IN DYNAMICWEB. Version: English

DEMO ONLY VERSION. Easy CramBible Lab M Magento Front End Developer Certification Exam. ** Single-user License **

Content Management System

CARSTORE RESPONSIVE MAGENTO THEME

EBOX Digital Content Management System (CMS) User Guide For Site Owners & Administrators

Installation, Configuration, and Usage

DPD shipping module documentation. Magento module version 2.0.3

User Guide. From Getting Started... To Getting More From Your Store. Magento Community Revised, Expanded, and Updated for Magento Community v1.

Going Beyond SAP ITS Mobile Apps to a Responsive Design Mobile Apps. JK (JayaKumar Pedapudi) Principal Consultant NTT DATA, Inc.

Exercise 1 : Branding with Confidence

E-Commerce Installation and Configuration Guide

BT CONTENT SHOWCASE. JOOMLA EXTENSION User guide Version 2.1. Copyright 2013 Bowthemes Inc.

Joostrap Template Documentation

Mistral Joomla Template

Speed Up Magento Web Store Via Magento Extension Support By: M-Connect Media. Prepared By: M-Connect Media

Microsoft Expression Web

ultimo theme Update Guide Copyright Infortis All rights reserved

Instead, there should only be one URL for the home page to avoid duplication.

~~Free# SEO Suite Ultimate free download ]

INTRO TO THEMING IN MAGENTO

ecommerce LMS Administrator s Manual

User s Guide. Version 2.1

SEO Checker User manual

SEO Suite Pro. User Guide

Bazaarvoice for Magento

Portals and Hosted Files

Product Personalization. User manual

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

SAHARA FASHION15 RESPONSIVE MAGENTO THEME

EXAM - M Magento Front End Developer. Buy Full Product.

Django Assess Managed Nicely Documentation

CS412 Interactive Lab Creating a Simple Web Form

Improving Madcap Flare SEO

MASTERTAG DEVELOPER GUIDE

E-Commerce Installation and Configuration Guide

Google Analytics Guide

Launch Create Store. Import Orders Enter Orders Manually Process Orders. Note: Ctrl+click on a number to jump to that topic.

JTouch Mobile Extension for Joomla! User Guide

Magento Quotation Module User and Installer Documentation Version 2.2

How to work with the WordPress themes

Content Management System

SmallBiz Dynamic Theme User Guide

Transcription:

Designing for Magento View 1. Creating a new theme a. How to duplicate a design theme b. How to setup new theme in administration area c. Adding custom stylesheets and js libraries to theme(part I) d. Changing META section 2. Understanding layout XML files a. Introduction b. Layout / page structure c. Reference name values d. Action methods e. Layout blocks d. Examples 3. Skinning templates a. Files structure b. Dependencies between files c. Adding custom CSS and JS files to layout (part II) 4. Appendix a. CSS tutorials b. HTML tutorials c. PHP / ZendFramework tutorials ================================================= 1. Creating a new theme a. How to duplicate a design theme The first step will be duplicating actual theme folder structure so we can always turn back the changes if we damage anything. Standard Magento s template structure looks like below, and we must duplicate 2 folders. Duplicating means creating a new folder with the same contents as the source. The simpliest method is copying the folder from original theme or duplicating with SSH or another client. Base folder structure: /app/design/frontend/default/default/ - theme customizations /skin/frontend/default/default/ - is where design themes css and images are Lets name the new template as new_theme. Then the new folder structure should look like this: New folder structure: /app/design/frontend/default/default - default theme /app/design/frontend/default/new_theme/ - our new, duplicated theme /skin/frontend/default/default - is where design themes css and images are /skin/frontend/default/new_theme/ - our new, duplicated skins folder Of course we don t need to duplicate the whole structure.if the file will not be found in the new_theme it will be taken from default. b.how to setup new theme in administration area After duplicating the folders we need to switch the theme from the administration area. Step 1. Go to System->Configuration->Design section Step 2. Input new_theme in default text field Step 3. Press the Save config button in the upper right corner 1 of 9 9/11/07 12:26 PM

c. Adding custom stylesheets and js libraries (part I) Any external stylesheet files (css) or javasript/ajax libraries (js) that we want to include in our new project must be also copied to proper folders. Stylesheets Copy the files to /skin/frontend/new_template/default/css folder Don t forget to include new file in styles.css file. We can do this by adding a @import url('your_new.css'); After @import url('custom.css'); Javascript / AJAX libraries Create a new folder under /js named custom_js and copy there your files. If you are using libraries that is also a good place to put the files into. 2. Using XML to change layout With the use of XML we can change most every aspect of our new_template for example set another column layout for particular pages, change META information, page encoding, block types used on page etc. XML files in every folder are referring to the View which we want to change. There are always initlayout.xml files which control the View and additional XML files for extending the defaults. a. Changing META section The main and the most important file to set up new values for META section is config.xml file placed in app/design/frontend/new_template/default/etc folder. Below is a short description of every META tag and possible values: <title>magento Commerce</title> This is the name of our ecommerce site. We can change at our own sweet will. <media_type>text/html</media_type> This is default page header encoding so we should leave this as is. <charset>utf8</charset> UTF8 is a variable-length character encoding for Unicode. It is able to represent any character in the Unicode standard, yet the initial encoding of byte codes and character assignments for UTF-8 is backwards compatible with ASCII table. For these reasons, it is steadily becoming the preferred encoding for e-mail, web pages, and other places where characters are stored or streamed. Of course we can change it to any other encoding ex. ISO-8859-1 or ISO-8859-2 but there is no need as long as we re saving our files with proper UTF8 encoding. More about UTF8 in Wiki: http://en.wikipedia.org/wiki/utf-8 <description>default Description</description> The description tag allows us to put there more information about our site. It s often a way to get a nice description of your page to show up in the search results if your page does rank highly. Your best bet is to write a succinct sentence or 2 which 2 of 9 9/11/07 12:26 PM

use the keyword phrases that sum up the page content. <keywords>magento, Varien, E-commerce</keywords> The keywords tag is the place to put the most important words that refer to the site content. Best practices are saying that we will get best results when we put into no more than 500 characters in no more than 20 words. <robots>*</robots> The Robots META tag is a simple mechanism to indicate to visiting Web Robots if a page should be indexed, or links on the page should be followed. The content of the Robots META tag contains directives separated by commas. The currently defined directives are [NO]INDEX and [NO]FOLLOW. The INDEX directive specifies if an indexing robot should index the page. The FOLLOW directive specifies if a robot is to follow links on the page. The defaults are INDEX and FOLLOW. The values ALL and NONE set all directives on or off: ALL=INDEX,FOLLOW and NONE=NOINDEX,NOFOLLOW We can simple override the default Magento s mechanism by placing index,follow or noindex,follow or index,nofollow or noindex,nofollow but it is not reccomended The file config.xml contains also 2 additional tags, not connected with META but used as a default settings for every page in our shop. <logo_src>images/logo.gif</logo_src> This tag sets up a logo fo our page. The image logo.gif is placed in folder skin/frontend/new_template/default/images so if we want to change it we must copy there a new file. We can also create a new folder ex. new_images ald place there all new files used by template. Of course we can also simply overwrite actual file with a new one. <logo_alt>magento Commerce</logo_alt> Logo s alt tag describes our logo image and is mostly used by screen readers or browsers with image download disabled. If one of our customers uses a screen reader or has image download disabled he will se the alt text instead of image. 2. Understanding layout XML files a. Introduction Using xml instead of other methods (JSON,.ini files, include / require functions) allows us to change many aspects on our page without manually changing the.phtml files. This chapter reffers to our default theme so after changing the theme (as we have seen above) the paths will also change. b. Layout / page structure Your core Layout is defined by default.xml placed in /app/design/frontend/default/layout/core/default.xml It does 2 things: Firstly it definies the default layout for your store. By Default Magento uses a 3column layout, so it defines use of 3columns.phtml (Located in your template/page/ folder): <layoutupdate> <block type="page/html" name="root" output="tohtml"> <action method="settemplate"><template>page/3columns.phtml</template></action> If you wanted to change your store to say, a 2column layout, you would change the line above to reflect the.phtml you d like to use. For example, If I wanted to change the store to a 2 column layout, I d change the line read: 3 of 9 9/11/07 12:26 PM

<action method="settemplate"><template>page/2columns-right.phtml</template></action> Possible values and action method reference is described in point d of this chapter. Secondly default.xml creates block containers filled with application data for output to your.phtmls. First, take a look at your standard 3column.phtml file you ll see it calls a variety of ChildHtml : (excerpt from 3columns.phtml - Starting at line 56): <?=$this->getchildhtml('header')?> /div><!-- [end] header --><!-- [start] middle --><div class="main-container"> <div id="main" class="col-3-layout"> <?=$this->getchildhtml('breadcrumbs')?> <!-- [start] left --> <div class="col-left side-col"> <?=$this->getchildhtml('store')?> <?=$this->getchildhtml('left')?> </div> <!-- [end] left --> Each of these references point towards the block containers defined in your default.xml and subsequent Module.xml files. You ll notice a container for the left column, for the right, for content, and other standard areas. It serves up output for your.phtmls to use. Take a look at it: /app/design/frontend/default/core/default.xml <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"> <block type="core/text_list" name="left" as="left"> <block type="core/messages" name="global_messages" as="global_messages"> <block type="core/messages" name="messages" as="messages"> <block type="core/text_list" name="content" as="content"> <block type="core/text_list" name="right" as="right"> So basically your default.xml creates Data Blocks, your.phtml Outputs that data where you want it. Hence, the names for left, right and so forth in your.phtml. Even further, Your modules will update the available block containers with more specific content. For example, you ll notice once you navigate pass the frontpage and click a Category.. The Compare Box appears, Once you click down further.. The Layered Navigation appears. These blocks are made available via their specific initlayout.xml files. These initlayout.xml s update your default layout with more specific blocks.so for the compare box to appear.. it is set to show once you click into the actual Catalog. So it s located at layout/catalog/initlayout.xml Here s the code: <layoutupdate> <reference name="top.menu"> <block type="catalog/navigation" name="catalog.topnav"> <action method="settemplate"><template>catalog/navigation/top.phtml</template></action> <reference name="right"> <block type="catalog/product_compare_sidebar" name="catalog.compare.sidebar"> <action method="settemplate"><template>catalog/product/compare/sidebar.phtml</template></action> If you read the code.. and think about whats going on. It makes sense. <layoutupdate> is UPDATING your code with new blocks. How does it know where to put the new blocks? Well remember in your default.xml you defined block containers for left, right, etc. So when it says 4 of 9 9/11/07 12:26 PM

<reference name = "right"> it s telling Magento to insert the following block into the RIGHT column when you get into Catalog view. (Remember, its located at layout/catalog/) so it appears once you ve entered the catalog. It also defines a TEMPLATE for the new block to use, so for the example above the compare box has its own template located at catalog/product/compare/sidebar.phtml (in your template folder). Reference name values/attributes: As we ve seen, the references can use different attributes for displaying blocks on our page. Possible values are: root - we will change it mostly to set up another.phtml file as a root template ex. (1column.phtml, 2columns-left.phtml,2columns-right.phtml etc.) head - as this reffers to our <HEAD> section on page, we will use this reference name to reflect our changes in this section top.menu - defines our content for top menu section left - defines our content for left column right - as above but for right column content - defines blocks placed in main content of our page before_body_end - is used to add a block before end of our page so before </BODY> There are more reference names that we could use but they are more page-specific than for global use for example: customer_account_navigation customer_account_dashboard are used on our clients account page product.info.additional - sets up additional block for placing related items, shipping estimator etc. Action methods: Action methods allow us to change many theme settings without appending manual changes to our.phtml files. The most important are described below. settemplate Action method settemplate allows us to change the default.phtml file used in particular block. For example by navigating to app/design/frontend/default/default/layout/catalog/product/view.xml we can see the reference: <reference name="root"> <action method="settemplate"><template>page/2columns-right.phtml</template></action> and by using another <template> value we are allowed to change default.phtml file used on our products page. Possible values are: 1column.phtml 2columns-left.phtml 2columns-right.phtml 3columns.phtml one-column.phtml dashboard.phtml As we see in app/design/frontend/default/default/layout/checkout/cart.xml, there also additional 2 values for empty and non-empty cart <action method="setcarttemplate"><value>checkout/cart.phtml</value></action> <action method="setemptytemplate"><value>checkout/cart/noitems.phtml</value></action> <action method="choosetemplate"/> The method choosetemplate is used to set a template (setcarttemplate / setemptytemplate) depending on quantity of items in our cart. If we have more than 0 than the 5 of 9 9/11/07 12:26 PM

<action method="setcarttemplate"><value>checkout/cart.phtml</value></action> is used. If we have no items in cart than <action method="setemptytemplate"><value>checkout/cart/noitems.phtml</value></action> will be used. The function provided by a model looks like below: public function choosetemplate() { if ($this->getquote()->hasitems()) { $this->settemplate($this->getcarttemplate()); } else { $this->settemplate($this->getemptytemplate()); } } so that should clarify how we can use this switch. Depending on our needs we can write custom functions in our blocks and than assign a template depending on parameters returned by a function. addcss This method allows us to add an additional CSS file to our page on per-page basis or global for our template. When we ll use a reference name head and action method addcss by using <action method="addcss"><link>style.css</link></action> than our page will have an additional CSS attached, for example: <link rel="stylesheet" type="text/css" media="all" href="http://www.ourstore.com/skin/frontend/default/default/css/style.css" ></link As we can see, the <link> path reffers to the skin/frontend/default/default/css/ folder. addcssie This method is very similiar to the above but it will output a css file when a User-Agent is Internet Explorer or Maxthone. So using this method we can attach a css specific for those browsers. This is very helpful if our page will require changes in css depending on browser. <action method="addcssie"><link>style.css</link></action> Output in page source: 6 of 9 9/11/07 12:26 PM

<!--[if IE]> <link rel="stylesheet" type="text/css" media="all" href="http://www.ourstore.com/skin/frontend/default/default/css/style.css" ></link <![endif]--> addjs Above method allows us to attach a.js script in the same way as CSS. The script path reffers to the js/varien folder but we can change it to suit our needs. <action method="addjs">varien/script.js</action> It will add a script to our page with src attribute of src="http://www.ourstore.com/js/varien/product.js" addjsie - adding a.js file to head section of page and using it if User Agent is Internet Explorer If we can add different css files depending on User-Agent we can do the same with our.js files. Than we can use different scripts for our IE/Maxthone users and another for other browsers. <action method="addjsie">our/script.js</action> It will add a script to our page with src attribute of src="http://www.ourstore.com/js/our/script.js" > but also inside IE comments <!--[if IE]><![endif]--> setcontenttype This method can override default headers sent by our page to the browser. So we can set a text/xml instead of text/html (or another as we wish). <action method="setcontenttype"><content>text/xml</content></action> setcharset allows us to override default page encoding on per-page basis or global. As long as we are saving our files with proper encoding this ll be not neccesary. 7 of 9 9/11/07 12:26 PM

<action method="setcharset"><charset>iso-8859-2</charset></action> So in this case our page will have Central European encoding instead of default UTF-8 addlink addlink methods can be used to set a setting to which we cann reffer in our.phtml files also without manually changing the.phtml files. Example usage : By adding a block which was found in app/design/frontend/default/default/layout/customer/account.xml into our <reference name="content"> in app/design/frontend/default/default/layout/checkout/cart.xml we can allow coustomer to skip to the account information directly from cart. <block type="customer/account_navigation" name="customer_account_navigation" before="-"> <action method="settemplate"><template>customer/account/navigation.phtml</template></action> <action method="addlink" translate="label"><name>account</name><path>customer/account/</path><label>account Dashboard</label></action <action method="addlink" translate="label"><name>address_book</name><path>customer/address/</path><label>address Book</label></action <action method="addlink" translate="label"><name>account_edit</name><path>customer/account/edit/</path><label>account Information</label The cart.xml file should look like below <layoutupdate> <reference name="root"> <action method="settemplate"><template>page/1column.phtml</template></action> <reference name="content"> <block type="customer/account_navigation" name="customer_account_navigation" before="-"> <action method="settemplate"><template>customer/account/navigation.phtml</template></action> <action method="addlink" translate="label"><name>account</name><path>customer/account/</path><label>account Dashboard</label></action <action method="addlink" translate="label"><name>address_book</name><path>customer/address/</path><label>address Book</label></action <action method="addlink" translate="label"><name>account_edit</name><path>customer/account/edit/</path><label>account Information</label <block type="checkout/cart" name="checkout.cart"> <action method="setcarttemplate"><value>checkout/cart.phtml</value></action> <action method="setemptytemplate"><value>checkout/cart/noitems.phtml</value></action> <action method="choosetemplate"/> <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon"> <action method="settemplate"><template>checkout/cart/coupon.phtml</template></action> <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping"> <action method="settemplate"><template>checkout/cart/shipping.phtml</template></action> <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell"> <action method="settemplate"><template>checkout/cart/crosssell.phtml</template></action> </layoutupdate> Of course according to the previous references we can also change 8 of 9 9/11/07 12:26 PM

<action method="settemplate"><template>page/1column.phtml</template></action> in the above code to suit our needs. I ve used for example <action method="settemplate"><template>page/one-column.phtml</template></action> to show only our cart without other blocks. Layout blocks As we ve seen before, most of our xml files have <block> tag. It defines a type of block, its name and short name as so we can reffer to it n our page. Basic block structure looks like this: <block type="directory/currency" name="currency" before="-"> <action method="settemplate"><template>directory/currency.phtml</template></action> The type attribute sets up a Model for our block for example when we see: <block type="catalog/product_view_super_group" name="product.info.group" as="super_group"> The type reffers to the Model in app/code/core/mage/catalog/block/product/view/super folder named as group.php In another place we can se for example: <block type="customer/account_navigation" name="customer_account_navigation" before="-"> So the Model will be in app/code/core/mage/customer/block/account named as navigation.php 9 of 9 9/11/07 12:26 PM