Skip to content

iMi-digital/magento2-top-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IMI Top Header — Magento 2 Module

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.

About

This Magento 2 module provides a configurable top header banner.

Resources

License

Stars

Watchers

Forks

Packages

No packages published