imi/magento2-top-header 问题修复 & 功能扩展

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

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

imi/magento2-top-header

最新稳定版本:1.0.0

Composer 安装命令:

composer require imi/magento2-top-header

包简介

This module provides a configurable top header banner.

README 文档

README

A lightweight Magento 2 module that renders a configurable banner at the very top of every page. The banner can be enabled/disabled per scope and its text and colors can be customized from the Admin. Both Luma and Hyvä compatible.

Requirements

  • Magento 2.4.x

Installation

Install via Composer (recommended):

composer require imi/magento2-top-header

Then enable and register the module:

bin/magento module:enable IMI_TopHeader
bin/magento setup:upgrade
bin/magento cache:flush

If you are in production mode, also deploy static content as usual:

bin/magento setup:static-content:deploy -f

Configuration

Navigate to: Stores > Configuration > iMi > Top Header.

Scope support: Global, Website, Store View.

Available options:

  • imi_topheader/general/enable — Enable/disable the banner (Yes/No)
  • imi_topheader/general/text — Banner text (supports HTML; processed through Magento's template filter)
  • imi_topheader/general/text_color — Text color (hex or valid CSS color)
  • imi_topheader/general/background_color — Background color (hex or valid CSS color)

How it works (entry points)

  • Registration: src/registration.php
  • Layout injection: src/view/frontend/layout/default.xml
    • Adds a container top.header before page.wrapper and renders block IMI\TopHeader\Block\BannerText with template IMI_TopHeader::topheader.phtml when imi_topheader/general/enable is true.
  • Hyvä override: src/view/frontend/layout/hyva_default.xml
    • Reuses the same block but switches template to IMI_TopHeader::hyva/topheader.phtml when using the Hyvä theme.
  • Block: IMI\TopHeader\Block\BannerText (in src/Block/BannerText.php)
    • Reads configuration values and passes them to the view. The text value is filtered via Magento's widget/template filter.

Theming

You can customize the look by overriding the corresponding PHTML in your theme, or by adjusting the configuration colors.

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-06