magento2前端开发主题[一]

2017-04-12  本文已影响0人  pointline

magento2前端对设备的支持情况:

magento2主题路径

创建一个主题

开发之前有些先决条件

为了兼容性,可升级性和易于维护,不要修改magento自带的主题,需要定义自己的主题
在开发主题时需要将magento应用程序设置为开发者模式(developer),

查看当前magento应用程序在什么模式下,默认是default:
<path to php binary> <magento install dir>/bin/magento deploy:mode:show
修改为developer或production模式
<path to php binary> <magento install dir>/bin/magento deploy:mode:set developer

创建

app/design/frontend/<your_vendor_name>/<your_theme_name>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>New theme</title> <!-- your theme's name -->
     <parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
     <media>
         <preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
     </media>
 </theme>
{
    "name": "magento/theme-frontend-peter",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/theme-frontend-blank": "100.0.*",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-theme",
    "version": "100.0.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}
<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/<Vendor>/<theme>',
    __DIR__
);
<magento install dir>/vendor/magento/theme-frontend-luma/etc/view.xml
里面的内容拷贝到自己的view.xml中

那基本的自定义主题就完成了,当前主题继承自blank主题

blank_themeblank_theme

原文出自:https://pointline.github.io/2017/04/12/magento2%E5%89%8D%E6%AE%B5%E5%BC%80%E5%8F%91-%E4%B8%80/

上一篇 下一篇

猜你喜欢

热点阅读