-
對HTML5和CSS3的全面支持;
-
內置的LESS預處理器;
-
用RequireJS的異步模塊上傳 (無需手動添加代碼)
-
使用jQuery/jQuery UI 代替Prototype library;
-
使用 MagentoUI library (它包括所有必要的組件,用來展現簡單靈活的用戶界面)。
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd"> <title>simple</title> <parent>Magento/blank</parent> <media> <preview_image>media/simple.jpg</preview_image> </media> </theme>
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::THEME, 'frontend/Zou/simple', __DIR__ );
{ "name": "Zou/simple", "description": "N/A", "require": { "php": "~5.5.0|~5.6.0|~7.0.0", "magento/framework": "100.0.*" }, "type": "magento2-theme", "version": "100.0.1", "license": [ "OSL-3.0", "AFL-3.0" ], "autoload": { "files": [ "registration.php" ] } }
├── web/ │ ├── css/ │ │ ├── source/ │ ├── fonts/ │ ├── images/ │ ├── js/
<images module="Magento_Catalog"> ... <images/>
<?xml version="1.0"?> <view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd"> <media> <images module="Magento_Catalog"> <image id="category_page_grid" type="small_image"> <width>200</width> <height>200</height> </image> </media> </view>
-
服務端預編譯LESS;
-
使用less.js的客戶端預編譯LESS
@page__background-color: #484848; @text__color: #fff; @font-family__base: 'Arial', sans-serif;
在你刪除 /pub/static/frontend/Zou/simple/en_US和var/view_preprocessed目錄下的內容後,你會發現你網站的視覺效果已經變化了。
<theme_dir>/Magento_Catalog/layout/catalog_category_view.xml.
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="category.description" remove="true"/> </body> </page>
-
請求一個方法,“支配”父佈局的另一個方法;
-
需更改方法的參數數目;
-
使用remove屬性取消對block/container操作的delete命令;
-
爲blocks/containers添加XML屬性;
-
需刪除參數塊;
-
用 ‘blank’ layout handle重寫佈局文件來刪除layout handles
-
需修改layout handles的激活.
<theme_dir> |__/<Namespace_Module> |__/layout |__/override |__/base |--<layout1>.xml |--<layout2>.xml
<module_dir>/view/frontend/layout/<layout1>.xml <module_dir>/view/frontend/layout/<layout2>.xml
<theme_dir> |__/<Namespace_Module> |__/layout |__/override |__/theme |__/<Parent_Vendor> |__/<parent_theme> |--<layout1>.xml |--<layout2>.xml
<parent_theme_dir>/<Namespace>_<Module>/layout/<layout1>.xml <parent_theme_dir>/<Namespace>_<Module>/layout/<layout1>.xml
<module_dir>/view/frontend/templates/<path_to_templates>
<theme_dir>/<Namespace>_<Module>/templates/<path_to_templates>
<div data-block="minicart" class="minicart-wrapper"> <a class="action showcart" href="<?php /* @escapeNotVerified */ echo $block->getShoppingCartUrl(); ?>" data-bind="scope: 'minicart_content'"> <span class="cart-title hidden-xs"><?php /* @escapeNotVerified */ echo __('Shopping cart'); ?></span> <span class="counter total-qty empty" data-bind="css: { empty: cart().summary_count == 0 }, blockLoader: isLoading"> <?php /* @escapeNotVerified */ echo __('Products count:'); ?> <span class="counter-number"><!-- ko text: cart().summary_count --><!-- /ko --></span> <span class="counter-label"> <!-- ko if: cart().summary_count --> <!-- ko text: cart().summary_count --><!-- /ko --> <!-- ko i18n: 'items' --><!-- /ko --> <!-- /ko --> </span> </span> </a> <?php if ($block->getIsNeedToDisplaySideBar()): ?> <div class="block block-minicart empty" data-role="dropdownDialog" data-mage-init='{"dropdownDialog":{ "appendTo":"[data-block=minicart]", "triggerTarget":".showcart", "timeout": "2000", "closeOnMouseLeave": false, "closeOnEscape": true, "triggerClass":"active", "parentClass":"active", "buttons":[]}}'> <div id="minicart-content-wrapper" data-bind="scope: 'minicart_content'"> <!-- ko template: getTemplate() --><!-- /ko --> </div> </div> <?php endif ?> <script> window.checkout = <?php /* @escapeNotVerified */ echo \Zend_Json::encode($block->getConfig()); ?>; </script> <script type="text/x-magento-init"> { "[data-block='minicart']": { "Magento_Ui/js/core/app": <?php /* @escapeNotVerified */ echo $block->getJsLayout();?> }, "*": { "Magento_Ui/js/block-loader": "<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/loader-1.gif'); ?>" } } </script> </div>
<parent_theme_dir>/i18n/ (查看所有父主題) <current_theme_dir>/i18n/
php bin/magento i18n:collect-phrases --output="app/design/frontend/Singree/walkbeyond/i18n/en_US.csv" app/design/frontend/Singree/walkbeyond
app/design/frontend/OrangeCo/orange/i18n/en_US.csv
php bin/magento theme:uninstall [-c|--clear-static-content] {theme path} ... {theme path}
-
刪除主題文件夾app/design/frontend/<Vendor>/;
-
刪除 var/view_preprocessed/ 目錄下的內容;
-
刪除 pub/static/frontend 目錄下的內容/;
-
開啓Magento 2數據庫,找到theme表,刪除主題名字的字符串;
-
使用 php bin/magento cache:flush命令刷新並刪除緩存.
-
/<Vendor>_<Module> (非必須的; 對給定模塊存儲樣式、模板和佈局)
-
/<Vendor>_<Module>/web/css/source (非必須的; 存儲特定模塊: .ccs以及.less文件)
-
/<Vendor>_<Module>/layout (非必須的; 存儲主要擴展包或父主題佈局)
-
/<Vendor>_<Module>/layout/override/base (非必須的;存儲主主題的覆蓋佈局)
-
/<Vendor>_<Module>/layout/override/<parent_theme> (非必須的; 爲父主題存儲覆蓋佈局)
-
/<Vendor>_<Module>/templates (非必須的; 存儲模板可以覆蓋主模塊模板或父模板)
-
/etc/view.xml (如果主題沒有聲明是必須的; 存儲圖像配置信息)
-
/i18n (非必須的; 存儲翻譯詞彙.csv的文件)
-
/media (非必須的; 存儲預覽)
-
/web (非必須的; 可以從前端上傳的靜態文件)
-
/web/css/source (非必須的; 存儲Magento UI庫的全局元素以及覆蓋默認變量值 _theme.less文件)
-
/web/fonts (非必須的; 儲存主題字體)
-
/web/images (非必須的;儲存主題圖像)
-
/web/js (非必須的; 儲存javascript文件)
-
/composer.json (非必須的; 描述主題變量和元數據)
-
/registration.php (必須的; 用來註冊主題)
-
/theme.xml (非必須的; 存儲主題的基本數據和元數據; 使用它以防主題被聲明爲一個系統組件)