官术网_书友最值得收藏!

Magento theme inheritance

The frontend of Magento allows designers to create new themes based on the basic Blank theme, reusing the main code without changing its main structure. The fallback system is a theme's inheritance mechanism and allows the developers to create only the files that are necessary for customization.

The Luma theme, for example, uses the fallback system by inheriting the Blank theme's basic structure. The Luma theme's parent is declared in its theme.xml file:

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd"> 
    <title>Magento Luma</title> 
    <parent>Magento/blank</parent> 
    <media> 
        <preview_image>media/preview.jpg</preview_image> 
    </media> 
</theme> 

The inheritance works like an override system. You can create new themes by using the existent ones (parents) and by replacing (overriding) some existing file with the same name, but in your specific theme folder (child).

For example, if you create a new theme in folder app/design/frontend/<Vendor>/<theme>/ and declares Magento/blank as a parent theme, theme.xml file and registration.php, you have the entire blank theme structure ready to work in your new theme including RWD layouts and styles.

Let's say that you have a specific CSS available in the <theme_dir>/web/css folder. If you delete this file, the fallback system will search the file in the <parent_theme_dir>/web/css folder:

主站蜘蛛池模板: 澎湖县| 东乡族自治县| 资兴市| 五台县| 宣恩县| 娄烦县| 夏河县| 鸡西市| 博乐市| 沭阳县| 三穗县| 广水市| 维西| 察哈| 阿克苏市| 苏尼特右旗| 诏安县| 年辖:市辖区| 湛江市| 新田县| 炎陵县| 昌都县| 温州市| 南通市| 株洲县| 颍上县| 郸城县| 蒙山县| 聂拉木县| 奎屯市| 浪卡子县| 洛浦县| 陇川县| 岐山县| 正镶白旗| 镇赉县| 历史| 琼结县| 北海市| 乌兰察布市| 岳普湖县|