See what's new with us. Take a look at the piece of Magento universe, through experience of our programmers. Keep up to date with new web technologies!

Magento Design – Explanation of exceptions

If you look in System> Configuration> General> Design -> Theme and Package section, notice that Magento provides “Add Exception” button for most parameters. There is also a headline that says, “Pair expressions  in the same order as they appear in the configuration.”

What does it mean and what can we do with this? If you’re adventurous and take a look at the code that stands for exceptions option, you will notice that Magento uses the usual array of regular expressions in “Matched Expression” field and compares them with the browser user-agent, it adds “value” to be used, instead of the default one that is given, if we find an appropriate mate. In other words, if an item is out of normal range of expression with the web browser used by the user, the set of exceptions applies.

You can use the following option to check what search engine users use to access your online store, and specify a different package / template / skin / layout / theme according to the result. So if you want to set a different theme for mobile browsers, recognizing this exception will be useful.

Let’s look at how to set up the service for iPhone Magento theme for mobile phones of your customers.

This is the complete content of the work, “Matched Expression”:
iPhone | iPod | BlackBerry | Palm | Googlebot-Mobile | Mobile | mobile | Mobile | Windows Mobile | Mobile Safari | Android | Opera Mini

This may not cover the complete list of web browser for mobile phones, but it will give you an idea. To check which one is your user agent, you can use this site:

When you enter strings make sure they are case-sensitive.

What the example in the picture says is: “If a user agent is from the list, use the iPhone design that is sent from Magento, otherwise use the default.”

Depending on where you add your exception, you can create a different layout or a full e-topic for your audience using a variety of devices to access your site. For example if you have a modern design for your default theme you can propose an alternative, more modest Versions for IE6 users. More often you will still use the exception of mobile optimized versions of your design.

And finally, what the cryptic title means at the beginning? This means that if you have more exceptions, they will be paired up and applied in the order in which they appear.

Other posts