Magento Custom Theme Creation
To Create a new theme first we have to understand the Magento Directory Structure
- /app – Here all the php codes of applications resides.
- /lib -The external code library.
- /skin -Here the css,js and images resides.
/app
Now we take a short brief of /app and /skin directory for theme creation. First we start with /app directory, it consists of:
- /app/etc -Global configuration
- /app/code -Here all modules resides
- /app/design – it contains template files and layout files
/app/design
Lets take an overview of /design directory. layout, template are the core directories that contain the files that make up your themes.
- /adminhtml -Admin panel designs
- /frontend – Front End designs
/app/design/frontend
/”custom_package”/”custom_theme”/default -theme customizations
- / layout – .xml files ,it define block structure
- / template – .phtml templates
layouts are saved as per module basis therefore you can easily locate the layout file to modify with the help of the Template Hints. First, enable Template Hints,
1. Admin->System->Configuration.
2. Select the store from current configuration scope eg Main Website
3.Advance->Developer.
4.Debug->Template Path Hints->yes.
5.Add Block Names to Hint->Yes click on save configuration.
Reload the the page, and look at the path of the template file that the Template Hints will provide you with. If you want to (for instance) move the mini cart, reference the template path (ex:app/design/frontend/default/default/checkout/cart/sidebar.phtml) and use the first folder name inside the theme folder (indicated in bold, which is the module name) to find the according layout file. So in the case of the mini cart, you know to look in ‘checkout.xml’ to modify the mini cart positioning. Each layout file(should it be necessary) further sections into per-page basis layout command. Each area of per-page layout is clearly marked with comments reflecting its usage, but the application itself recognizes the layout separation by the handles of each layout.
After listing is complete, you will create the phtml markups for each structure type and save them as skeleton templates into app/design/frontend/custom_package/custom_theme/template/page/.The getChildHtml method is used to insert the structural block for instance
[php]<?php echo $this->getChildHtml(‘header’) ?> [/php]
Here Header value is passed as a parameter which refer to header.phtml
/skin
In /skin/ we find CSS, images, JavaScript and any other resource files that relate specifically to templates in the system.
- /frontend – frontend styles directory
- /default – Our default interface
- /default -our default theme
- /default/css -contains .css files
- /default/images -contains images
- /default/js -contains js
/skin/frontend/custom_package/custom_theme/default -css customization
Any external stylesheet files (css) that you want to include in your custom theme must be also
copied to css folders.we must include this file in the page.xml located in app/design/frontend/custom_package/custom_theme/default/layout.for instance
[php]
<action method="addCss"><stylesheet>css/styles.css</stylesheet></action>
[/php]
we can also customise the css as per our requirement by using (for instance)firebug and then save the changes.
Any images that you want to add in your custom theme must be copied to the images folder
Any external javasript libraries (js) that you want to include in your custom theme must be also
copied to js folders.
set the new package
- Admin->System->Configuration
- then on the left upper set the Current Configuration Scope
- Design->Package->”new_theme_name” click on Save Config
Disable Cache
- Admin->System->Cache Management
- In the Cache Storage Management section forall cache type select action disable and clickon submit button.
Regards
Akash Sethi
akash@intelligrape.com