magento2.2 override topmenu.php: _addSubMenu()Override topmenuCould not create an acl object: Invalid XML in fileAbout I/O Usage in magento2.2Create observer for Magento2.2Problem with block override in Magento 2Magento2.2 refused to apply stylesheetUnable to create/visualize productsHow to override tax Block In magento2Cannot add custom topmenu link with pluginGoogleAnalytics Block Override
How to terminate ping <dest> &
Maths symbols and unicode-math input inside siunitx commands
Deletion of copy-ctor & copy-assignment - public, private or protected?
When did antialiasing start being available?
Comment Box for Substitution Method of Integrals
Do US professors/group leaders only get a salary, but no group budget?
What is the term when voters “dishonestly” choose something that they do not want to choose?
Should I be concerned about student access to a test bank?
Do I need to be arrogant to get ahead?
Probably overheated black color SMD pads
Is there a term for accumulated dirt on the outside of your hands and feet?
How does 取材で訪れた integrate into this sentence?
How to define limit operations in general topological spaces? Are nets able to do this?
How is the partial sum of a geometric sequence calculated?
Does .bashrc contain syntax errors?
What can I do if I am asked to learn different programming languages very frequently?
Could Sinn Fein swing any Brexit vote in Parliament?
Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?
In Aliens, how many people were on LV-426 before the Marines arrived?
Asserting that Atheism and Theism are both faith based positions
두음법칙 - When did North and South diverge in pronunciation of initial ㄹ?
Suggestions on how to spend Shaabath (constructively) alone
Why didn't Héctor fade away after this character died in the movie Coco?
How to generate binary array whose elements with values 1 are randomly drawn
magento2.2 override topmenu.php: _addSubMenu()
Override topmenuCould not create an acl object: Invalid XML in fileAbout I/O Usage in magento2.2Create observer for Magento2.2Problem with block override in Magento 2Magento2.2 refused to apply stylesheetUnable to create/visualize productsHow to override tax Block In magento2Cannot add custom topmenu link with pluginGoogleAnalytics Block Override
I am trying to override the Topmenu Module Block but I can not understand why it fails.
I am trying to override the following method:
magento/module-theme/Block/Html/Topmenu.php:_addSubMenu(...)
I have created the following folders/files:
app/code/Custom/Theme/Block/Html/Topmenu.php (If it works, "lala" should be appeared at the menu):
Topmenu.php
<?php
namespace CustomThemeBlockHtml;
class Topmenu extends MagentoThemeBlockHtmlTopmenu
protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
$html = '';
if (!$child->hasChildren())
return $html;
$colStops = null;
if ($childLevel == 0 && $limit)
$colStops = $this->_columnBrake($child->getChildren(), $limit);
$html .= '<ul class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '<li>lala</li></ul>';
return $html;
protected function _toHtml()
$this->setModuleName($this->extractModuleName('MagentoThemeBlockHtmlTopmenu'));
return parent::_toHtml();
app/code/Custom/Theme/etc/ has two files:
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoThemeBlockHtmlTopmenu" type="CustomThemeBlockHtmlTopmenu" />
</config>
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Custom_Theme" setup_version="0.0.1" />
</config>
And the registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Custom_Theme',
__DIR__
);
Is this approach correct? What do I miss?
magento2.2 topmenu override-block
bumped to the homepage by Community♦ 29 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I am trying to override the Topmenu Module Block but I can not understand why it fails.
I am trying to override the following method:
magento/module-theme/Block/Html/Topmenu.php:_addSubMenu(...)
I have created the following folders/files:
app/code/Custom/Theme/Block/Html/Topmenu.php (If it works, "lala" should be appeared at the menu):
Topmenu.php
<?php
namespace CustomThemeBlockHtml;
class Topmenu extends MagentoThemeBlockHtmlTopmenu
protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
$html = '';
if (!$child->hasChildren())
return $html;
$colStops = null;
if ($childLevel == 0 && $limit)
$colStops = $this->_columnBrake($child->getChildren(), $limit);
$html .= '<ul class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '<li>lala</li></ul>';
return $html;
protected function _toHtml()
$this->setModuleName($this->extractModuleName('MagentoThemeBlockHtmlTopmenu'));
return parent::_toHtml();
app/code/Custom/Theme/etc/ has two files:
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoThemeBlockHtmlTopmenu" type="CustomThemeBlockHtmlTopmenu" />
</config>
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Custom_Theme" setup_version="0.0.1" />
</config>
And the registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Custom_Theme',
__DIR__
);
Is this approach correct? What do I miss?
magento2.2 topmenu override-block
bumped to the homepage by Community♦ 29 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
Did you ever get this working?
– Stephen Dance
May 18 '18 at 15:43
Did you? I'm working on this right now. Would love to know.
– JustinP
Nov 8 '18 at 2:01
@JustinP Anyone manage to get this working can you share?
– Juliano Vargas
Jan 15 at 14:20
add a comment |
I am trying to override the Topmenu Module Block but I can not understand why it fails.
I am trying to override the following method:
magento/module-theme/Block/Html/Topmenu.php:_addSubMenu(...)
I have created the following folders/files:
app/code/Custom/Theme/Block/Html/Topmenu.php (If it works, "lala" should be appeared at the menu):
Topmenu.php
<?php
namespace CustomThemeBlockHtml;
class Topmenu extends MagentoThemeBlockHtmlTopmenu
protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
$html = '';
if (!$child->hasChildren())
return $html;
$colStops = null;
if ($childLevel == 0 && $limit)
$colStops = $this->_columnBrake($child->getChildren(), $limit);
$html .= '<ul class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '<li>lala</li></ul>';
return $html;
protected function _toHtml()
$this->setModuleName($this->extractModuleName('MagentoThemeBlockHtmlTopmenu'));
return parent::_toHtml();
app/code/Custom/Theme/etc/ has two files:
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoThemeBlockHtmlTopmenu" type="CustomThemeBlockHtmlTopmenu" />
</config>
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Custom_Theme" setup_version="0.0.1" />
</config>
And the registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Custom_Theme',
__DIR__
);
Is this approach correct? What do I miss?
magento2.2 topmenu override-block
I am trying to override the Topmenu Module Block but I can not understand why it fails.
I am trying to override the following method:
magento/module-theme/Block/Html/Topmenu.php:_addSubMenu(...)
I have created the following folders/files:
app/code/Custom/Theme/Block/Html/Topmenu.php (If it works, "lala" should be appeared at the menu):
Topmenu.php
<?php
namespace CustomThemeBlockHtml;
class Topmenu extends MagentoThemeBlockHtmlTopmenu
protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
$html = '';
if (!$child->hasChildren())
return $html;
$colStops = null;
if ($childLevel == 0 && $limit)
$colStops = $this->_columnBrake($child->getChildren(), $limit);
$html .= '<ul class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '<li>lala</li></ul>';
return $html;
protected function _toHtml()
$this->setModuleName($this->extractModuleName('MagentoThemeBlockHtmlTopmenu'));
return parent::_toHtml();
app/code/Custom/Theme/etc/ has two files:
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoThemeBlockHtmlTopmenu" type="CustomThemeBlockHtmlTopmenu" />
</config>
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Custom_Theme" setup_version="0.0.1" />
</config>
And the registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Custom_Theme',
__DIR__
);
Is this approach correct? What do I miss?
magento2.2 topmenu override-block
magento2.2 topmenu override-block
asked Dec 21 '17 at 23:01
user2447482user2447482
61
61
bumped to the homepage by Community♦ 29 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 29 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
Did you ever get this working?
– Stephen Dance
May 18 '18 at 15:43
Did you? I'm working on this right now. Would love to know.
– JustinP
Nov 8 '18 at 2:01
@JustinP Anyone manage to get this working can you share?
– Juliano Vargas
Jan 15 at 14:20
add a comment |
1
Did you ever get this working?
– Stephen Dance
May 18 '18 at 15:43
Did you? I'm working on this right now. Would love to know.
– JustinP
Nov 8 '18 at 2:01
@JustinP Anyone manage to get this working can you share?
– Juliano Vargas
Jan 15 at 14:20
1
1
Did you ever get this working?
– Stephen Dance
May 18 '18 at 15:43
Did you ever get this working?
– Stephen Dance
May 18 '18 at 15:43
Did you? I'm working on this right now. Would love to know.
– JustinP
Nov 8 '18 at 2:01
Did you? I'm working on this right now. Would love to know.
– JustinP
Nov 8 '18 at 2:01
@JustinP Anyone manage to get this working can you share?
– Juliano Vargas
Jan 15 at 14:20
@JustinP Anyone manage to get this working can you share?
– Juliano Vargas
Jan 15 at 14:20
add a comment |
1 Answer
1
active
oldest
votes
You need to specify the usage of the new block via XML. Add the following to your theme's default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class=“VendorModuleBlockHtmlTopmenu" name="catalog.topnav" template="Magento_Theme::html/topmenu.phtml" ttl="3600" before="-"/>
</referenceContainer>
</body>
</page>
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f206826%2fmagento2-2-override-topmenu-php-addsubmenu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to specify the usage of the new block via XML. Add the following to your theme's default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class=“VendorModuleBlockHtmlTopmenu" name="catalog.topnav" template="Magento_Theme::html/topmenu.phtml" ttl="3600" before="-"/>
</referenceContainer>
</body>
</page>
add a comment |
You need to specify the usage of the new block via XML. Add the following to your theme's default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class=“VendorModuleBlockHtmlTopmenu" name="catalog.topnav" template="Magento_Theme::html/topmenu.phtml" ttl="3600" before="-"/>
</referenceContainer>
</body>
</page>
add a comment |
You need to specify the usage of the new block via XML. Add the following to your theme's default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class=“VendorModuleBlockHtmlTopmenu" name="catalog.topnav" template="Magento_Theme::html/topmenu.phtml" ttl="3600" before="-"/>
</referenceContainer>
</body>
</page>
You need to specify the usage of the new block via XML. Add the following to your theme's default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class=“VendorModuleBlockHtmlTopmenu" name="catalog.topnav" template="Magento_Theme::html/topmenu.phtml" ttl="3600" before="-"/>
</referenceContainer>
</body>
</page>
answered Jan 23 at 14:25
mluntmlunt
769
769
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f206826%2fmagento2-2-override-topmenu-php-addsubmenu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Did you ever get this working?
– Stephen Dance
May 18 '18 at 15:43
Did you? I'm working on this right now. Would love to know.
– JustinP
Nov 8 '18 at 2:01
@JustinP Anyone manage to get this working can you share?
– Juliano Vargas
Jan 15 at 14:20