I am trying to create a theme with Magento Blank as parent in Magento 2 but I can't figure it out how to change the header with a custom one.
I first remove header.container from magento blank and create my container but it is created inside page-wrapper between main-content and footer and I can't make it go before main-content.
This is my layout.xml:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="register-link" remove="true" />
<referenceBlock name="authorization-link" remove="true" />
<referenceBlock name="wish-list-link" remove="true" />
<referenceBlock name="my-account-link" remove="true" />
<referenceBlock name="top.links" remove="true" />
<referenceBlock name="header.panel.wrapper" remove="true" />
<referenceBlock name="header.container" remove="true" />
<referenceContainer name="page.wrapper">
<container name="custom.header" htmlClass="headerSection" htmlTag="div">
<block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml">
</block>
</container>
</referenceContainer>
</body>
</page>
And this is how it looks the HTML:
Related
How do I remove a link from customer menu when customer group is general?
I know about the ifconfig tag, but it does not give me the possibility to hide a custom link when a customer in the general group.
I use Magento 2.2.4.
class Current extends \Magento\Framework\View\Element\Html\Link\Current //block
{
/**
* #return string
*/
public function toHtml()
{
if (SOME CONDITION HERE) {
return parent::toHtml(); //show link
}
return ''; //hide link
}
//Layout
<referenceBlock name="customer_account_navigation">
<block class="...\Current" name="customer-account-navigation-product">
<arguments>
<argument name="path" xsi:type="string">.../index</argument>
<argument name="label" xsi:type="string">Product</argument>
</arguments>
</block>
</referenceBlock>
Step 1:
First of all, you need a create customer_account.xml in your theme in:
app/design/frontend/_YOUR_VENDOR_/_YOUR_THEME_/Magento_Customer/layout/customer_account.xml
Step 2: Add Remove the link to the file:
To shorten and simplify the story, in the example below I will immediately show you how to delete all links from the navigation one by one.
<!-- Store credit -->
<referenceBlock name="customer-account-navigation-customer-balance-link" remove="true"/>
<!-- Downloadable product link -->
<referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>
<!-- Subscription link -->
<referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>
<!-- Billing agreement link -->
<referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
<!-- Product review link -->
<referenceBlock name="customer-account-navigation-product-reviews-link" remove="true"/>
<!-- My credit card link -->
<referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>
<!-- Account link -->
<referenceBlock name="customer-account-navigation-account-link" remove="true"/>
<!-- Account edit link -->
<referenceBlock name="customer-account-navigation-account-edit-link" remove="true"/>
<!-- Address link -->
<referenceBlock name="customer-account-navigation-address-link" remove="true"/>
<!-- Orders link -->
<referenceBlock name="customer-account-navigation-orders-link" remove="true"/>
<!-- Wish list link -->
<referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
<!-- Gift card link -->
<referenceBlock name="customer-account-navigation-gift-card-link" remove="true"/>
<!-- Gift registry -->
<referenceBlock name="customer-account-navigation-giftregistry-link" remove="true"/>
<!-- Reward points -->
<referenceBlock name="customer-account-navigation-reward-link" remove="true"/>
<!-- Order by SKU -->
<referenceBlock name="customer-account-navigation-checkout-sku-link" remove="true"/>
Please view more detail in https://inchoo.net/magento-2/managing-my-account-navigation-links-magento-2/
I want to remove navbar from a custom magento admin panel popup. I have already removed header and footer, but can not remove navbar panel.
Please help
<remove name="footer" />
<remove name="header" />
<remove name="top.menu" />
<remove name="top.links" />
<remove name="top.container" />
<reference name="content">
<remove name="nav-bar" />
<remove name="header" />
<block type="core/template" name="xyz" template="abc/test/test.phtml" />
</reference>
Simple way,But I don't know this is better way or not but it's working.
Go to
C:\Xampp\htdocs\your project\app\design\adminhtml\default\default\template\page\menu.phtml
Then comment or delete the menu like as below
<div class="nav-bar">
<!-- menu start -->
<?php //echo $this->getMenuLevel($this->getMenuArray()); ?>
<!-- menu end -->
<a id="page-help-link" href="<?php echo Mage::helper('adminhtml')->getPageHelpUrl() ?>"><?php echo $this->__('Get help for this page') ?></a>
<script type="text/javascript">$('page-help-link').target = 'magento_page_help'</script>
</div>
After changed the code please clear the cache.
Simple way for hide the top menu of admin panel in magento.
Please follow the below steps:
open file adminhtml.xml ;
Location : /app/code/core/Mage/Adminhtml/etc/adminhtml.xml
Note : It is core file so,please override this module(best way).
<!-- Custom work for hide admin menu links -->
<catalog translate="title">
<depends><config>HideMe</config></depends>
</catalog>
<system translate="title">
<depends><config>HideMe</config></depends>
</system>
<sales translate="title">
<depends><config>HideMe</config></depends>
</sales>
<promo translate="title">
<depends><config>HideMe</config></depends>
</promo>
<report translate="title">
<depends><module>HideMe</module></depends>
</report>
<customer translate="title">
<depends><module>HideMe</module></depends>
</customer>
<newsletter translate="title">
<depends><module>HideMe</module></depends>
</newsletter>
<cms translate="title" module="adminhtml">
<depends><module>HideMe</module></depends>
</cms>
<!--Custom work for hide admin menu links end-->
It's working fine.
Thanks
Pradeep kumar
I am adding tabs from xml to product view page, but I want to apply separate css class on one of the tab.
<action method="addTab" translate="title" module="catalog" >
<alias>description_tabbed</alias>
<title>My Tab</title>
<block>catalog/product_view_description</block>
<template>catalog/product/view/description.phtml</template>
</action>
How can I add class to it? I tried the following:
<action method="addTab" translate="title" module="catalog" >
<alias>description_tabbed</alias>
<liParams>
<class>myclassname</class>
</liParams>
<title>My Tab</title>
<block>catalog/product_view_description</block>
<template>catalog/product/view/description.phtml</template>
</action>
How can i add another element after <li>
So i can get this tree structure <ul><li><span><a>Logout</a></span></li></ul>
Currently my rendered html is looking like this. I want to have span element to do bit more with logout. I have tried a lot but no luck. Please help. Thank you
<ul class="links">
<li class="first last">
Logout
</li>
</ul>
layout to top.links is
<customer_logged_in>
<reference name="account.links">
<action method="addLink" translate="label title" module="customer">
<label>Logout</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<liParams></liParams>
<aParams>class="logout-link"</aParams>
</action>
<action method="removeLinkByUrl">
<url helper="customer/getRegisterUrl" />
</action>
</reference>
If i am changing the links.phtml then change will apply for all the links or else i need to put if else in there but i needed it only for logout. so what is the best way to do that?
Is this achievable using addLinks method?
You can do this using the beforeText and afterText parameters, like this:
<action method="addLink" translate="label title" module="customer">
<label>Logout</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<liParams></liParams>
<aParams>class="logout-link"</aParams>
<beforeText><![CDATA[<span>]]></beforeText>
<afterText><![CDATA[</span>]]></afterText>
</action>
Which will modify your link to look something like this:
<li class="first last">
<span>Logout</span>
</li>
You can create your own template (a copy of links.phtml) and apply it only for Top Links.
Do it like this in your theme's local.xml:
<default>
<reference name="top.links">
<action method="setTemplate">
<template>page/template/my_links.phtml</template>
</action>
</reference>
<default>
Then copy page/template/links.phtml and rename it to page/template/my_links.phtml and do whatever you need inside that new template file. It will be only used to render Top Links, not for any other links
if I have a template in
app\design\frontend\base\default\template\dir\template.phtml
that look like this
<div class='block block-list'>
<div class='block-title'><strong><span>Some Block</span></strong></div>
<div class='block-content'>
<?php echo "my content"; ?>
</div>
</div>
How can I show it on a catalog page using local.xml? Shouldn't this code work?
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="right">
<block type="core/template"
name="somename"
template="dir/template.phtml" />
</reference>
</default>
</layout>
I think you can not have custom layout handle<catalog_category_default translate="label"> inside default layout handle<default>
Correct me if I am wrong.
You have to use template reference name before that reference tag.
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<catalog_category_default translate="label">
<reference name="right">
<block type="core/template"
name="somename"
template="dir/template.phtml" />
</reference>
</catalog_category_default>
</default>
</layout>