One of the nice surprises at Magento Imagine 2014 was the simultaneous release of Magento EE 1.14 andMagento CE 1.9. The most obvious feature of both is a new responsive web design theme, but behind the scenes there was some invisible systems work done to finally bring a simpler infinite theme fallback system to Magento. In this article we’re going to cover Magento CE 1.9’s new parent/child theme system.
Creating a new Theme in Magento 1.9
Let’s create and enable a new Magento 1.9 theme, and do so under a new design package. First, we’ll create a folder for the theme
$ mkdir app/design/frontend/pulsestorm/default
Next, we’ll enable the theme in the backend by changing the design package to pulsestorm
, and blanking out the theme information (which Magento will then fill in with default
)
Technically, that’s all we need to do to create a new theme. However, if we load the home page, we’ll see something most designers would call “a broken site”
Magento’s design package/theme system has grown organically over the years. Unfortunately, neither Magento’s engineering culture or Magento’s ecommerce culture really understood the needs of modern front end developers or creative/interactive agency workers, and the system has suffered for that.
It’s not that the design package system didn’t offer feature X, but that feature X’s implementation ran counter to other popular CMS systems, and did so with Magento’s long standing problem of a technically valid configuration making undesirable things happen.
The above is an example of this. We’ve created a new design package, and Magento correctly “falls back” to the base design package for missing phtml
and layout update XML files. However, CSS files are missing, image links are incorrect, etc. To create a new design package there’s going to be a lot of duplicate information added to thedesign
and skin
folders, and it’s not always straight forward to figure out what needs to go where.
Fortunately, we wouldn’t be talking about this if these wasn’t a fix in Magento 1.9. Specifically, Magento’s introduced a theme configuration file named theme.xml
. This file allows theme developers to specify a parent theme, and it couldn’t be simpler. First, we’ll create an etc
folder for our theme
$ mkdir app/design/frontend/pulsestorm/default/etc
Next, we’ll add the following XML configuration file
1
2
3
4
5
|
<!-- File: app/design/frontend/pulsestorm/default/etc/theme.xml --> <? xml version = "1.0" ?>
< theme >
< parent >default/modern</ parent >
</ theme >
|
Now if we clear our Magento cache and reload the homepage, we’ll see our theme looks and acts exactly like thedefault/modern
theme that ships with Magento.
Parent/Child Themes
What we’ve done is tell Magento that our new theme is a child of the modern
theme. A child theme will behave exactly like its parent, unless we add a new template, layout, etc. file to the child. Magento appears to have introduced this feature to make it much simpler for designers to base their designs on the new rwd/default
theme.
If we change the above to
1
2
3
4
5
|
<!-- File: app/design/frontend/pulsestorm/default/etc/theme.xml --> <? xml version = "1.0" ?>
< theme >
< parent >rwd/default</ parent >
</ theme >
|
and clear our cache, this tells our system we want to base the theme on the response web design theme. If we wanted to replace the head.phtml
file for our theme, it would be as simple as adding a new file to our theme
app/design/frontend/pulsestorm/default/template/page/html/head.phtml
Remember — the point here isn’t that this sort of thing wasn’t possible with previous versions of Magento — it’s that it simplifies the configuration dramatically if you want to create a new theme that starts from an existing Magento theme that isn’t base/default
, and that this inheritance can work across Magento design packages.
One last note before we wrap up — the parent/child theme system still uses the “replace this theme file with this new theme file” pattern. Unlike newer features in Magento 2, files are not merged into one another. In other words, if you replace catalog.xml
then you need to include all the existing code from therwd/default/layout/catalog.xml
file, (or all the code you want).
Wrap Up
It’s a long running joke of mine that Magento 2 is a lot like perl 6 — and now it looks like that works both ways. The addition of the theme.xml
file to Magento 1 was clearly inspired by changes made to Magento 2. Much like the modern perl movement started bringing parts of perl 6 back into perl 5, if parts of Magento 2 end up inspiring changes to the 1.x branch that’s a big win for us as we wait for Magento 2 to make its debut.
It’s also great to see eBay embracing the design agency community — both with this responsive theme and a design track at Magento Imagine 2014. Ecommerce and “design” have always had a shaky relationship, and it’s encouraging to see these small steps towards a better design experience.
相关推荐
这个标题"magento-1.9.1.1-2015-04-30-12-49-08"指的是Magento的一个特定版本,即1.9.1.1,发布于2015年4月30日,具体时间是12:49:08。这个版本包含了该阶段Magento系统的所有更新、修复和增强功能。 Magento 1.9....
在本文中,我们将深入探讨Magento 1.9.2.0版本,这是一个针对网站开发和商务独立站的老版64位系统。 首先,让我们了解Magento 1.9.2.0的核心特性: 1. **强大的商品管理**:Magento 1.9.2.0允许商家管理大量商品,...
1.9.3.8 是 Magento 的一个版本号,这表明该压缩包包含的是 Magento 1 系列的一个更新版本,发布日期为2018年2月23日,时间戳5:50:58。这个版本可能包含了安全性修复、性能优化以及一些功能改进,旨在提供更稳定和...
Magento 1.9.0.1 是一个流行的开源电子商务平台,专为在线商家提供高度定制化和功能丰富的购物体验。这个版本是Magento的早期稳定版本,具有多项改进和增强的功能,旨在提高性能、安全性和用户体验。 一、Magento ...
Magento1.9-CatalogPriceRulesFix Magento CE 1.9.1 和 EE 1.14.1.0 中的目录价格规则核心错误(数组到字符串转换错误和不正确的价格规则行为) 问题的简短摘要 - 如果您的 Magento 目录价格规则在条件中具有多个...
Magento 1.9.1.0 是一个流行的开源电子商务平台,专为商家提供高度可定制的网上购物体验。这个俄罗斯语言包是针对 Magento 1.9.1.0 版本设计的,目的是为了让俄罗斯用户在使用 Magento 商店时能够享受母语环境,提升...
Magento1.9多语言安装教程,最新安装中英文,亲测成功。
Vue店面对Magento 1.9的支持该项目使您能够将Magento 1.9用作的后端平台。 Vue店面是电子商务的独立PWA店面。 可以通过API与任何电子商务后端(例如Magento,Pimcore,Prestashop或Shopware)联系起来。 在 (与...
Magento 2-空白主题-SASS版本 Magento 2 Blank主题的基于SASS的版本,旨在尽可能接近核心代码。 安装 将此添加到您的项目依赖列表中, composer require snowdog/theme-blank-sass 将您的应用程序设置为developer...
Ajax-magento2-catalog-infinite-scroll.zip,免费的Magento 2扩展,为目录添加无限滚动功能(通过AJAX实现)编码教程,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。...
magento2-developer-quickdevbar, Magento2的开发人员工具栏 Magento2开发人员工具栏 希望这个调试工具栏能够加速Magento2开发模块。 如果你想改进这个工具栏的任何反馈和想法,那么你可以通过GitHub上的追踪器...
magento1.9.2.2源码集成的中文翻译及各部分中国用插件,如支付,社交等扩展; 当前版本magento 1.9.2.2 zh_CN简体中文翻译zh_TW繁体中文翻译CosmoCommerce支付宝CosmoCommerce银联支付CosmoCommerce社交登录付通...
magento2-Ho_Templatehints, h& 2高级模板提示模块 h& 2高级模板提示模块[Overview $0 ] ( 文档/总 workings.gif )Ho_Templatehints扩展了默认的Magento模板提示。使用肌肉存储器 ?ath=1 轻松访问。显示hints模
Magento 1.9 是一款强大的开源电子商务平台,用于构建和管理在线商店。它以其灵活性、可扩展性和丰富的功能集而闻名。在这个名为 "shopme" 的项目中,我们看到一个基于 Magento 1.9 构建的商店实例,这可能包括...
Ajax-magento2-ajax-cart-quick.zip,magento 2 ajax购物车扩展插件提供舒适的购物体验。客户可以很容易地选择可配置的选项并在弹出窗口中编辑项目,而不会浪费重新加载页面的时间。,ajax代表异步javascript和xml。它...
magento2-blog-module-tutorial, 关于如何从头开始创建 magento 2模块的教程,带有测试 2博客模块教程这个模块是 WIP,它将被更新为每个教程我目前正在写。介绍如何从头创建完整功能的Magento 2模块。 即使有测试,...
压缩的Magento 1.9样本数据提供以下变体: 65M 64M 40M 26M 24M 19M 样本数据包的大小为317MB,这很荒谬,由于找不到合适的替代来源,我决定一起整理一个小脚本,以压缩样本中的图像和MP3文件数据存档。 我的意图是...
Ajax-magento2-ajax-layered-navigation.zip,ajax分层导航magento 2提供了一个过滤器列表,帮助您的客户以最短的方式搜索和获得他们最喜欢的产品。这个扩展应用了现代ajax技术来增强过滤系统,以提高用户对页面上每...
Ajax-magento2-ajax-cart.zip,ajax add to cart for extension magento 2提供了通过ajax弹出窗口将产品添加到购物车的主要功能。它通过允许客户从产品列表页面将任何产品类型添加到购物车,显著改善了用户体验。,...
如何给产品描述里的关键字、字词批量添加链接?我想大家一直在的这样的插件。...说明请查看:http://www.hicoogle.com/magento-gei-chan-pin-miao-shu-guan-jian-zi-pi-liang-lian-jie-cha-jian.html