semexpert/module-store-info-blocks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

semexpert/module-store-info-blocks

Composer 安装命令:

composer require semexpert/module-store-info-blocks

包简介

Enables developers to include Magento blocks in their themes that have access to Store Configuration like address, phone number, etc.

README 文档

README

SemExpert_StoreInfoBlocks enables developers to include Magento blocks in their themes that have access to Store Configuration like address, phone number, etc.

Build Status

Getting Started

To get started you only need to add the module to an existing Magento2 installation.

Prerequisites

You need a running copy of Magento2

Also, in order for composer to locate the module repository, you need to have set up SemExpert repository:

composer config repositories.semexpert composer https://packages.semexpert.com.ar/

Install

To get StoreInfoBlocks up and running, you need to add it as a dependency to your Magento composer.json file

composer require semexpert/module-store-info-blocks

Or add it manually to your composer.json

{
  "require": {
    "semexpert/module-store-info-blocks": "*"
  }
}

After installing, you need to enable via the Magento CLI

php bin/magento module:enable SemExpert_StoreInfoBlocks

Running tests

This module provides only unit tests that can be hooked into Magento testsuite in the standard way

php bin/magento dev:tests:run unit

In order to run this module's tests exclusively you can use the provided dev/phpunit.xml configuration file.

vendor/bin/phpunit -c vendor/semexpert/moodule-store-info-blocks/dev/phpunit.xml

I found no need for integration or functional tests as of yet. And also I am unsure about how to write those.

Coding Styles

The module follows Magento 2.2 PHP and Less coding standards. You should test your code using the provided black/white lists and phpunit.xml configuration.

cp ./dev/tests/static/phpunit.xml dev/tests/static/phpunit.xml
cp ./dev/tests/static/less/whitelist/common.txt dev/tests/static/testsuite/Magento/Test/Less/_files/whitelist/common.txt
cp ./dev/tests/static/php/whitelist/common.txt dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt

Magento 2

Components

The module provides 2 types of blocks

  • SemExpert\StoreInfoBlocks\Block\Template Provides a stadard Template block with access to store configuration information
  • SemExpert\StoreInfoBlocks\Block\Value Allow to output a single configuration value without formatting. Requires some setup via layout xml

These blocks are available for use in your custom themes but are not automatically included anywhere on the site.

Usage

Template

By simply calling the Template block in a layout, the provided storeinfo.phtml template will be used which is provided only as an example

<?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>
        <referenceContainer name="header.panel">
            <block class="SemExpert\StoreInfoBlocks\Block\Template" name="header.storeinfo" />
        </referenceContainer>
    </body>
</page>

or you can provide your own template. Within the template, you can access a DataObject containing the store information by calling $block->getStoreInformation()

default.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>
        <referenceContainer name="header.panel">
            <block class="SemExpert\StoreInfoBlocks\Block\Template" name="header.storeinfo" 
                   template="storeinfo-modal-window.phtml" />
        </referenceContainer>
    </body>
</page>

storeinfo-modal-window.phtml

<?php $storeInfo = $block->getStoreInformation(); ?>
<div class="call-us">
    <strong>Call Us at:</strong> <?= $storeInfo->getData('phone') ?> <?= $storeInfo->getData('hours') ?>
</div>

Available data keys are:

  • name
  • phone
  • hours
  • street_line1
  • street_line2
  • city
  • postcode
  • region_id
  • region
  • country_id
  • country
  • vat_number

Value

You can set up a value block via layout XML to retrieve a single unformatted value

contact_index_index.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="contactForm">
            <block class="SemExpert\StoreInfoBlocks\Block\Value" name="storephone">
                <arguments>
                    <argument name="key" type="xsi:string">phone</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

app/design/SemExpert/CustomTheme/Magento_Contact/templates/form.phtml

<form>
    <!-- ... -->
</form>

<p>
    Or call us at <a href=tel:<?= $block->getChildHtml('storephone') ?>"><?= $block->getChildHtml('storephone') ?></a>
</p>  

Check the description for Template block for a list of accepted values for the key argument.

Versioning

We use SemVer for versioning. To see available versions, check the tags for this repository.

Authors

  • Matías Montes - Initial work - barbazul

Also check the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Thanks to everybody involved in this thread that served as an inspiration for the module.
  • alepasian and lupeportias for hacking your way into M2 limitations.

统计信息

  • 总下载量: 3.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 13
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固