`
kirenenko04
  • 浏览: 151013 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

Magento IE Only Stylesheet

 
阅读更多

Sometimes you want to enable IE only stylesheets for Magento. The problem is that the documentation to accomplish this is somewhat lacking. I decided to shed some light on a solution to help you out on your journey to success. It’s a simple solution for IE 6, 7, 8 and 9! In order to understand these methods, you’re going to need to understand CSS Conditional Statements in addition to Magento Layouts.

 

IE 7 and Below

 

If you look within the default layout file (design/frontend/base/default/layout/page.xml), you’ll notice that Magento already provides an example of how to recognize IE 7 and below and execute the css/styles-ie.css upon success. If you look around line 55 of the page.xml, you’ll notice a line that looks like this:

 

PS. I broke it up into multiple lines so that it’s more readable.

<action method="addItem">
    <type>skin_css</type>
    <name>css/styles-ie.css</name>
    <params/>
    <if>lte IE 7</if>
</action>

 Basically, all it says is that we’re going to add a CSS file (css/styles-ie.css) if the version of IE is less than 8. If you look at line 5 from the code snippet above, you’ll notice our conditional statement that looks for IE. The condition “lt IE 8″ stands for LESS THAN IE 8.

 

What does this mean? It means that all we’re doing is checking to see if the browser detected is IE7 or older. If it is, include the stylesheet we named (styles-ie.css). If you go back to the CSS Conditional Statements, it will explain the available conditions in more detail.

 

If we want to add an IE only stylesheet, all we need to do is include the snippet above into our page.xml within the head block. Once you update your page.xml, simply go into the skin/frontend/mytheme/css/ directory and add your styles-ie.css file with all your IE7- styling.

 

What about IE 8 and 9?

 

Great! The solution above works for the older versions of IE, but what about IE 8 and 9? Unfortunately, sometimes can be a little tricky when handling multiple versions of stylesheets. We can simply use the above snippet, change the condition for execution, and target another stylesheet for the newer versions of IE. It will look something like this:

 

<action method="addItem">
    <type>skin_css</type>
    <name>css/styles-ie7-and-up.css</name>
    <params/>
    <if>gte IE 8</if>
</action>

 Boom! We changed our condition to if the browser detected is GREATER THAN IE 7! Now all we need to do is go to our skin/frontend/mytheme/css/ directory and add the styles-ie7-and-up.css file with all your IE7+ styling.

 

It’s Not Working

 

Sometimes this solution doesn’t always work for the newer versions of IE and you cant figure out why…Don’t worry, it’s not your fault. Blame Microsoft! If you want to read a little bit more about the problem check out Alan Storm: IE9 fix for Magento.

 

The solution is simple. Basically we’re going to tell the newer versions of IE (8,9) to function as if they were IE7. Hence, our IE7 stylesheet will be all that we need in order to get the styling we need.

 

You do this by adding two tags within your HTML tags. The file you need to edit is either in your design/frontend/base/default/template/page/html/head.phtml or within your current template directory if it exists.

 

Add the following meta tags:

    <!-- set cinoatubake ue 8  -->
       <block type="core/text" name="head.compatibleie8">
          <action method="setText"><text><![CDATA[<meta http-equiv="X-UA-Compatible"  content="IE=edge,chrome=1"  />]]>&#10;</text></action>
      </block>

 WARNING: It is not recommended to edit the above design/frontend/base/default/template/page/html/head.phtml directly. This is considered a *core* hack if you do. Please read the Intro To Layouts in order to learn out how to make the changes the correct way.

 

分享到:
评论

相关推荐

    Magento在IE下登陆不了后台破解方法文件

    然而,由于浏览器兼容性问题,有时用户可能会遇到在Internet Explorer(IE)上无法登录Magento后台的情况。这个问题通常是由 Magento与某些旧版IE之间的交互问题引起的,可能涉及到JavaScript的执行、CSS渲染或者与...

    magento快速复制网站_magento_magento快速复制站_

    在电商领域,经常会有需求将一个已经建立并运行良好的Magento站点快速复制到另一个服务器,用于测试、备份或者创建一个新的独立站点。这个过程涉及到数据库的备份与还原、文件系统的复制以及配置的调整等多个步骤。 ...

    magento数据结构分析

    标题:“Magento数据结构分析” 描述:“Magento数据字典”提供了对Magento系统中各种数据库表的深入理解,这对于理解和优化Magento的性能至关重要。 一、Magento数据结构解析 Magento是一款功能强大的电子商务...

    magento二次开发大全

    Magento是一款强大的开源电子商务平台,以其高度可定制性和灵活性著称。在进行Magento的二次开发时,你需要理解并掌握以下几个核心概念和技术: 1. **MVC架构**:Magento基于Model-View-Controller(MVC)设计模式...

    Magento-SMTP-Email

    Magento是开源的电子商务平台,广泛用于在线商店的建设。SMTP(Simple Mail Transfer Protocol)是用于发送电子邮件的标准协议。在Magento中,SMTP插件扮演着关键角色,它允许商家通过更安全、可靠的SMTP服务器发送...

    magento入门学习资料

    Magento是一款强大的开源电子商务平台,以其高度可定制性和灵活性著称。作为一款基于PHP开发的系统,它为商家提供了丰富的功能,包括商品管理、订单处理、客户管理、营销工具等。以下将详细介绍`magento入门学习资料...

    magento-java-master.zip_magento

    这个“magento-java-master.zip_magento”压缩包可能是为了提供一个Java连接Magento源码的示例或者库,帮助开发者实现Java与Magento系统的交互。 在Java中与Magento进行交互通常涉及到以下几个关键知识点: 1. **...

    magento2 developers cookbook

    根据给定文件信息,以下为《Magento 2 Developer's Cookbook》一书中的知识点介绍。 首先,《Magento 2 Developer's Cookbook》是一本针对Magento 2开发的指导手册,它向开发者提供了实用的食谱来解决在Magento 2...

    magento图片延时加载插件

    Magento是一款强大的开源电子商务平台,它的灵活性和可扩展性使得开发者能够根据需求定制各种功能。在电商网站中,图片是至关重要的元素,它们可以展示产品细节,吸引顾客注意力。然而,大量的图片也会对网站性能...

    magik shoes magento 模板, magento 1.7 模板

    Magento是一款开源的电子商务平台,专为在线商家设计,提供强大的购物车系统和丰富的功能。"Magik Shoes Magento 模板"是专为Magento 1.7版本设计的商店主题,旨在提升在线鞋类销售商店的用户体验和视觉吸引力。在这...

    Magento插件开发手册 Magento Extension Developers Guide

    Magento是一款强大的开源电子商务平台,为开发者提供了广泛的定制和扩展能力。《Magento插件开发手册》是一份详尽的指南,旨在帮助开发者理解Magento的核心架构、编码标准以及如何创建和部署自定义插件。 ### ...

    Magento php开发指南

    Magento是一款流行的开源电子商务平台,其功能强大且模块化,它支持在线零售业务的创建和管理。Magento使用PHP语言编写,它为开发者提供了丰富的扩展性和灵活性,使得定制网站功能和外观成为可能。本指南是为后台...

    magento商城数据库

    Magento 商城数据库是一个关键组成部分,它是 Magento 电子商务平台的核心,负责存储所有商品信息、客户数据、订单记录以及网站配置等重要信息。Magento 是一个开源的电子商务解决方案,以其强大的功能和高度可定制...

    Magento

    3. **获取Magento代码**:你可以从Magento官网下载最新版本的源码,或者通过Composer拉取Magento 2的代码。 4. **解压并上传**:将下载的Magento源码解压到Web服务器的根目录,例如 `/var/www/html`。 5. **运行...

    magento官方文档翻译超好

    ### Magento官方文档翻译超好——深入理解Magento数据层操作与数据封装 #### 一、引言 Magento是一款基于PHP的企业级电子商务平台,以其强大的功能、灵活性以及可扩展性著称。在Magento中,数据处理是一个核心组成...

    Magento 常用方法和插件

    Magento是一款强大的开源电子商务平台,以其高度可定制性和灵活性著称。在Magento的开发过程中,掌握常用的方法和插件是提高工作效率的关键。这篇博客"Magento 常用方法和插件"可能涵盖了以下方面: 首先,关于...

    开源网店系统 Magento

    Magento是一款强大的开源电子商务平台,由Varien公司开发,并在2008年首次发布。它以其高度可定制性、丰富的功能集以及灵活的架构而受到全球电商从业者的广泛青睐。这款网店系统的出现,为中小型企业提供了与大型...

    The Definitive Guide to Magento (Apress出品 Magento权威指南)

    ### Magento权威指南 #### 书籍概述 《Magento权威指南》是由Adam McCombs与Robert Banh共同编著的一本深入探讨Magento电商平台的技术手册。该书由Apress出版社于2009年出版发行,旨在为读者提供一个全面、系统的...

    Magento 2 Cookbook

    Magento 2 is installable only via the command-line interface for an experienced webmaster. Chapter 2, Magento 2 System Tools, explains how to install Magento 2 via the command shell. Magento released ...

Global site tag (gtag.js) - Google Analytics