Magento themes and the developers who can create them are in high demand.
Developing Magento themes for specific clients or for resale on template marketplaces can provide a nice bit of incremental income for savvy web developers. And, from a technical standpoint, creating a Magento theme is not much of a challenge.
About this Magento Theme Series
This article is the second in a series of posts created to walk you through developing a Magento theme from start to finish—line-by-line. These articles are aimed at intermediate level web developers and designers, and will discuss all of the major steps and development decisions associated with theme creation. The theme being created in these articles, which I call Pine, will be used on a live store, so this is not just some kind of coding exercise. It is a real Magento store theme in the making.
In the first article, I briefly discussed some of the business decisions behind the Pine Theme, for example, I said that we wanted to include site badges (trust symbols), have lots of merchandising, and engage customers. I showed you a mock-up of the graphic design, and I mentioned that we would not be creating our theme from nothing, rather we are going to start with the Modern Theme from the Magento Core team and build from there.
The Series' Links
- Part One: Prolegomena
- Part Two: Page Planning, Templates, & HTML 5
- Part Three: HTML Validation and "Your" Labels
- Part Four: The CSS Work Begins
- Part Five: The Home Page CSS Continues
- Part Six: Product Navigation and CSS Rounded Corners
- Part Seven: More Rounded Corners
- Part Eight: The Boring Middle
- Part Nine: A Content Slider
- Part Ten: The Home Page Home Stretch
- Part Eleven: The Footer
- Part Twelve: The Search Form
- Part 13: Turning the Page
- Part 14: Facing the Horror
- Part 15: Style and Graphics for the Category Page Sidebar
- Part 16: Category Page Image and Font
- Part 17: The Category Page Grid
- Part 18: CSS for the Product Detail Page
- Part 19: Smooth Sliding Tabs
Page Planning
The next step in the theme development process is to identify which and how many pages I am going to need to develop. Now, thanks to the Modern Theme, nearly all of the pages I want have been created in some form or another. I just need to identify them so that I am sure to address each one with the appropriate CSS, JavaScript, or other changes. I do this bit of page planning in a simple Microsoft Excel spreadsheet. I track the page, its template in Magento, and the status of any PHP, HTML, CSS, and JavaScript updates. You may also want to track the status of page content if you are building your theme for an actual site, but you won't need to monitor content if you are creating your theme for resale on a theme marketplace.
Magento Connect to Get the Base Theme
To start, I need to get the Modern Theme. Get an extension key from the Modern Theme page on the Magento website. Navigate to Magento Connect in the store backend, and follow the instructions for including this theme extension.
Avoiding Cookie Problems
If, like me, you also got a few updates when you installed the Modern Theme, and, like me, you are developing on a localhost, you may have some new cookie problems.
Magento sets session cookies. And most browsers won't allow cookies to be set from the localhost. As a side effect of this cookie incompatibility, you may not be able to login to your store backend anymore. But have no fear, this is a pretty simple fix. In fact, if you’re working with Magento on a localhost for the first time, I recommend that you see my earlier article, Avoid Two Problems Installing Magento On A Localhost that describes this cookie fix and points out some PHP extensions you'll need. For the purpose of this theme creation, I am going to comment out session cookies. To accomplish this, I will need to navigate to Varien.php. The path is app/code/core/Mage/Core/Model/Session/Abstract.
I'll find the code for setting session cookie parameters, which should look like this:
// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath(),
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
I'll comment out the final three lines, being certain to remove the comma after $this->getCookie()->getPath().
// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
// $this->getCookie()->getDomain(),
// $this->getCookie()->isSecure(),
// $this->getCookie()->getHttponly()
File Copying and Theme Selection
Once I have downloaded the Modern Theme, I am going to copy its two folders and rename those copies to Pine. In the Magento admin, I will identify Pine as the theme to use for my store.
HTML 5 Document Type and Sections
Next I am going to change the document type to <!DOCTYPE HTML> and add semantic sections like <header> and <footer> to the PHTML template for the home page, so that our home page will be in HTML 5.
Summing Up
In this article (and video), I took you through the next several steps necessary to build a Magento Theme. In our next episode, I will start to change the CSS, work with layout, and add a content slider to the home page using Magento's CMS features.
Related Articles
- Tutorial: Avoid Two Problems Installing Magento On A Localhost
- Magento Commerce Theme Basics
- Segmentation Made Simple: Magento Enterprise 1.6 Makes It Easy to Show Visitors What They Want to See
This article is filed under Open Source and has the following keyword tags: Magento, theme, tutorial, HTML 5.
18 Comments
sideradesign says:
Armando, This screencast series is really promising, and I'm just getting started with Magento theming, so it couldn't arrive at a better time. There isn't much quality info about magento on the web, so you're filling in a void. I bought the Magento theme design book, but I don't really like it, not all examples work and it's confusing, so I'm looking forward to your explanations, up until now they are very clear. One remark though, if you'll allow me : I think you're talking too much about the details of HTML, I'd rather get more Magento specifics. I think you can assume that your audience knows how to code HTML. Just a thought. Are you familiar with the Yoast blank seo theme? what do you think of it? Can you recommend other useful resources? Hope this wasn't too long a comment! When's the next episode?
keep up the good work Paul
Oliver Schörwerth says:
Very interesting video. I think its very good for beginners.
I already know how to build up Magento themes but i was interested how other build their shops and (the main reason i klicked this howto) i am interested in html5.
By the way: i started a howto serie (in german) especially for new Magento-Storeowner. There i planed to first give an overview about all admin panel components and after that an explenation how to create products, price rules and so on: http://swebdesign.blogspot.com/
P.S. You have very good stuff here :)
Armando Roggio says:
@Oliver, Thank you for the comment. I took a look at your site. Wish my German was better. But I expect and hope you will get a lot of readers.
http://swebdesign.blogspot.com/2010/01/magento-admin-panel-uberblick-uber-die.html
tcraw1010 says:
Greetings:
I have very much been enjoying your newsletters and articles - especially your ongoing series on working with themes in Magento. I was wondering why you would want to modify things so as to utilize HTML 5 within the Magento code. (I'm not arguing it, just curious as to the benefits).
I am very much looking forward to your next installments in the series. Your hands on demonstrations are helping me greatly in understanding the inner workings of Magento (something the books just seem to fall short of).
Looking forward to hearing from you.
TOM
Armando Roggio says:
@Tom
I am using HTML 5 for a few reasons.
- It's time. The HTML 5 specification is now five and half years old. And the last call to changes or comments to the spec was four months ago.
- It's supported. Every major browser offers some level of HTML 5 support, and Google is driving HTML 5 hard. You can expect every browser except IE to support most of the cool stuff within the next year.
- I want the theme to last. Unless you want to change themes every year, you should be using the HTML 5 DTD now. I believe it will be the dominate DTD for new and redesigned sites within the next four years.
- It is more powerful. HTML 5 makes things like video native to the browser. No plugin required. I will be using this feature in the Pine theme.
- It offers geolocation. HTML 5 can geolocate the client with user permission. This feature will be especially powerful for mcommerce.
tcraw1010 says:
When will Part 3 be released ??
Armando Roggio says:
@tcraw1010 in about 10 hours. We bumped it for the Mozilla announcement. So it will be published at about 7am MST.
mc_pickles says:
great site and awesome tutorial, Armando. Noticed one dupe in your html updating though, you have the lang attribute twice in your , otherwise very helpful. looking forward to future videos and ecomm advice, tips & strategy.
Armando Roggio says:
@mc_pickles, You're right about the double lang tag. I actually caught it and fixed it in the next video.
guyen says:
I'm having some problems installing the modern theme. I tried it with my settings be at stable, beta and alpha. This is what I get,
downloading InterfaceFrontendDefault_Modern-1.3.2.2.tgz ... Starting to download InterfaceFrontendDefault_Modern-1.3.2.2.tgz (654,851 bytes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...done: 654,851 bytes downloading MageCoreModules-1.3.2.4.tgz ... Starting to download MageCoreModules-1.3.2.4.tgz (1,625,826 bytes) ...done: 1,625,826 bytes downloading Lib_Varien-1.3.2.2.tgz ... Starting to download Lib_Varien-1.3.2.2.tgz (112,925 bytes) ...done: 112,925 bytes Could not download from "http://connect.magentocommerce.com/core/get/LibGoogleCheckout-1.2.0.tgz", cannot download "magento-core/LibGoogleCheckout" (Connection to connect.magentocommerce.com:80' failed: Operation timed out) Error: cannot download "magento-core/LibGoogleCheckout" downloading LibJsMage-1.3.2.3.tgz ... Starting to download LibJsMage-1.3.2.3.tgz (70,330 bytes) ...done: 70,330 bytes downloading LibJsPrototype-1.3.2.tgz ... Starting to download LibJsPrototype-1.3.2.tgz (220,016 bytes) ...done: 220,016 bytes downloading Lib_ZF-1.7.2.4.tgz ... Starting to download Lib_ZF-1.7.2.4.tgz (1,252,569 bytes) ...done: 1,252,569 bytes downloading LibZFLocale-1.7.2.2.tgz ... Starting to download LibZFLocale-1.7.2.2.tgz (1,279,370 bytes) ...done: 1,279,370 bytes magento-core/MageCoreModules requires package "magento-core/LibGoogleCheckout" (version >= 1.2.0, version <= 1.3.3, excluded versions: 1.3.3) magento-core/InterfaceFrontendDefaultModern requires package "magento-core/MageCore_Modules" (version >= 1.3.2.2, version <= 1.3.3, excluded versions: 1.3.3) install ok: channel://connect.magentocommerce.com/core/LibJsPrototype-1.3.2 install ok: channel://connect.magentocommerce.com/core/LibZFLocale-1.7.2.2 install ok: channel://connect.magentocommerce.com/core/LibJsMage-1.3.2.3 install ok: channel://connect.magentocommerce.com/core/Lib_ZF-1.7.2.4 install ok: channel://connect.magentocommerce.com/core/Lib_Varien-1.3.2.2
I am currently running this on mamp.
Armando Roggio says:
@guyen, Have you check your PHP extensions?
jfa528 says:
Armando, First of all, thanks you SO much for these amazing tutorials. I wouldn't know what to do without you.
I am, however, running into a very strange issue. Take a look at this image here: http://imgur.com/EtQvS.png
If you'll notice, only 2 of all the path hints on the page are referencing my theme called "mytest." The rest are going to the default theme because it is not finding the file in the mytest folders. I go into those folders and sure enough, the files are not there.
For example, if I navigate to the top path hint, 2columns-right.phtml does not exist in my "mytest" folder, only 3columns.phtml does.
Initially, I thought this was because I was using the modern theme that was pre-installed with Magento now, so I installed the extension thinking it may be different (like the one you have), but same results, the magento extension does not have the 2columns-right.phtml file in it nor many other files.
Upon watching your video, I noticed that right away, ALL the path hints went right to your "pine" theme paths no problem...
Perhaps they have changed the modern theme file/folder hierarchy and are no longer shipping the 2 column template with it? I'm not sure...
I also tried to play around with the CMS->Pages screen to no avail.
I would really appreciate any advice or guidance...
Thanks so much, Justin
jfa528 says:
Hi Armando, This thread helped give me a few answers to my above questions. I think my problems were intermingled with the fact that magento has changed their frontend/base and frontend/default folder configuration.
The following thread explains it in a little more detail.
http://www.magentocommerce.com/boards/viewthread/79857/
Thanks, Justin
anubis says:
Hey,
Fantastic tutorials, thanks! I'm testing Magento 1.4 and have come up against the dreaded localhost cookies issue. Seems magento have changed the varien.php file, do you have a tutorial on how to modify the new one? :)
Cheers Matt
Chris says:
Thanks for pointing me in the right direction Justin. I was a little lost there for a bit. Seem like what you have to do now is copy all the relevant template files from the base folder into your new folder and then edit those.
frank65l says:
Hello Armando, I just started on this series, i have the latest version installed, after i copied and renamed the modern theme, i noticed i only have one template file in my pine/template/page folder, named 3 columns.phtml. I then went and reinstalled from Magento connect, the modern theme and still only have this one template in the modern or pine folders. The 2 column does seem to be available anymore? Anyone have any suggestions, Just looked at my home page and the "Template Path Hints" shows "2columns-right.phtml". I really need help with this.
phoobah says:
Hello Armando. I too recently started the series having installed the latest version 1.4. Will your series be revised with the new sub-folder structure base? (i.e. a new 'base' folder alongside 'default', which threw me for a loop when trying to follow "Template Path Hints" with your video.). I look forward to your response. Have been enjoying the series, thanks!
Armando Roggio says:
@phoobah, this series will finish out without the version change. But once these series is complete, I will be doing more tutorials that include the newer version.
