Showing results for 
Search instead for 
Did you mean: 

Custom block is not showed in header.panel

Custom block is not showed in header.panel

Stumbled on this issue:
I need to add a block which switches between Web-pages in a DropDown form.

I am using a custom theme here. Block must be located at this side LD0Qy

But the problem is, that when I trying to add a custom block to the container, it's not showing up.

<referenceContainer name="header.panel">
    <block class="<Vendor>\<Module>\Block\Theme\Header\Lang" name="lang_switch" before="header.links" template="<Vendor>_<Module>::language.phtml"/>

What I tried:

  1. Add this to app/design/frontend/<Vendor>/<Module>/Magento_Theme/layout/defalt.xml
  2. Add this to app/code/<Vendor>/<Module>/view/frontend/layout/default.xml

For knowing what content of blocks:



namespace <Vendor>\<Module>\Block\Theme\Header;

class Lang extends \Magento\Framework\View\Element\Template {

    public function __construct(\Magento\Framework\View\Element\Template\Context $context)

    public function render() {

        $label = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('mysetting/header_lang/hl_label');
        $s_data = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('mysetting/header_lang/hl_data');

        $data = array_map(function($el){
            $d = explode("|",$el);
            return array("order"=>intval($d[0]),"label"=>$d[1],"link"=>$d[2]);

        usort($data, fn($a,$b) => $a->order - $b->order );

        $html = '<div class="example-dropdown-2"><span class="action toggle" data-mage-init=\'{"dropdown":{}}\' data-toggle="dropdown" aria-haspopup="true"><span>'.$label.'</span></span><ul class="dropdown">';

        foreach ($data as $d){
            $html .= '<li> <a href="'.$d->link.'">'.$d->label.'</a></li>';
        $html .= '</ul></div>';

        return $html;


 * @var \<Vendor>\<Module>\Block\Theme\Header\Lang $block
echo $block->render();

Data structure of configs:

hl_label: text

hl_data: textarea

Any help with it?

  • Magento: 2.4.4
  • Server: CentOS
  • Installation: docker\bitnami\magento Docker
  • PHP: 8.1.9
  • MySQL: 8.0.30

Re: Custom block is not showed in header.panel

Hello @mykolakike6a30 


Please follow the steps below:

  • Open default.phtml file. (Path: app/design/frontend/<Vendor>/<Module>/Magento_Theme/layout/defalt.xml)
  • Please add the following code before <body> end:
    <move element="lang_switch" destination="header.panel" after="-"/>


If you find our reply helpful, please give us kudos.


A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.


WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

Thank You,

WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

Location: 150 King St. W. Toronto, ON M5H 1J9