Creating a custom navigation bar
I successfully created a module which outputs "Hello World" on my CMS homepage. Now, I want to make this module a header / navigation bar which replaces the one of the blank theme. I also successfully created my own theme. So I am basically good to go but I don't know where to start. The structure and workflow of Magento completely confuse me. How do I change the styling of a certain block / module? How do I tell the module to be on the very top of all pages? I know it has something to do with the default.xml
but... how? I got a "normal" HTML website with a gallery. I linked my shop there. I want to have a smooth transition from my HTML website to my magento shop meaning the design should match. So how do I get my header in magento to look like this?
magento2 module blocks theme
bumped to the homepage by Community♦ yesterday
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 successfully created a module which outputs "Hello World" on my CMS homepage. Now, I want to make this module a header / navigation bar which replaces the one of the blank theme. I also successfully created my own theme. So I am basically good to go but I don't know where to start. The structure and workflow of Magento completely confuse me. How do I change the styling of a certain block / module? How do I tell the module to be on the very top of all pages? I know it has something to do with the default.xml
but... how? I got a "normal" HTML website with a gallery. I linked my shop there. I want to have a smooth transition from my HTML website to my magento shop meaning the design should match. So how do I get my header in magento to look like this?
magento2 module blocks theme
bumped to the homepage by Community♦ yesterday
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 successfully created a module which outputs "Hello World" on my CMS homepage. Now, I want to make this module a header / navigation bar which replaces the one of the blank theme. I also successfully created my own theme. So I am basically good to go but I don't know where to start. The structure and workflow of Magento completely confuse me. How do I change the styling of a certain block / module? How do I tell the module to be on the very top of all pages? I know it has something to do with the default.xml
but... how? I got a "normal" HTML website with a gallery. I linked my shop there. I want to have a smooth transition from my HTML website to my magento shop meaning the design should match. So how do I get my header in magento to look like this?
magento2 module blocks theme
I successfully created a module which outputs "Hello World" on my CMS homepage. Now, I want to make this module a header / navigation bar which replaces the one of the blank theme. I also successfully created my own theme. So I am basically good to go but I don't know where to start. The structure and workflow of Magento completely confuse me. How do I change the styling of a certain block / module? How do I tell the module to be on the very top of all pages? I know it has something to do with the default.xml
but... how? I got a "normal" HTML website with a gallery. I linked my shop there. I want to have a smooth transition from my HTML website to my magento shop meaning the design should match. So how do I get my header in magento to look like this?
magento2 module blocks theme
magento2 module blocks theme
asked Sep 16 '16 at 10:40
Pixell
6618
6618
bumped to the homepage by Community♦ yesterday
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♦ yesterday
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 |
add a comment |
3 Answers
3
active
oldest
votes
If you declare something in default.xml , it will render in all the pages.
default.xml file looks like
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header">
<block class="ErSampleBlockTest" name="sample.test" before="-" template="Er_Sample::test.phtml"/>
</referenceContainer>
</body>
</page>
Create block file with necessary functions
In test.phtml
<?php echo "Welcome message in all magento pages!!!"; ?>
It will display in all pages header section.
add a comment |
Based off your input it sounds like you only want to change the styling?
If you want to make small styling changes you can extend the styling like so:
- Create this file -
app/design/frontend/Vendor/themename/Magento_Theme/web/css/source/_extend.less
- Add your styling here.
- Compile your styling, if you don't know how you can read about it here.
If you want to overwrite all the navigation styling then follow these steps:
- Copy this file into your theme -
vendor/magento/theme-frontend-blank/web/css/source/_navigation.less
->app/design/frontend/Vendor/themename/web/css/source/_navigation.less
- Make your styling changes in there
- Compile your styling, if you don't know how you can read about it here.
add a comment |
I may be late to give an answer for this question. But as a beginner of magento, I have the same problem as yours.
I have done it up to some extent and like to share the way I have done it.
1) I first create the basic layout structure of the header, using content tags in default.xml file
I placed this in the referenceContainer name="header.container" tags in default.xml file. The reason is, navigation bar goes to the header section.
2) Then I have created a phtml file in magento, which includes the content of the navigation bar. This should be in the Magento_Theme module(Magento_Theme module is a customized module of the module_theme in vendor folder. This customized module should be in, app->design->frontend->vendor->yourtheme->Magento_Theme)
3) After that, call this phtml file using a in between the layout structure where you want to place the nav bar.
e.g:block class="MagentoFrameworkViewElementTemplate" name="header.nav.section" template="Magento_Theme::custom/head_navbar.phtml" before="-"
Here I have created a head_navbar.phtml file which contains the content of nav bar
Hope this will help you.
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%2f136715%2fcreating-a-custom-navigation-bar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you declare something in default.xml , it will render in all the pages.
default.xml file looks like
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header">
<block class="ErSampleBlockTest" name="sample.test" before="-" template="Er_Sample::test.phtml"/>
</referenceContainer>
</body>
</page>
Create block file with necessary functions
In test.phtml
<?php echo "Welcome message in all magento pages!!!"; ?>
It will display in all pages header section.
add a comment |
If you declare something in default.xml , it will render in all the pages.
default.xml file looks like
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header">
<block class="ErSampleBlockTest" name="sample.test" before="-" template="Er_Sample::test.phtml"/>
</referenceContainer>
</body>
</page>
Create block file with necessary functions
In test.phtml
<?php echo "Welcome message in all magento pages!!!"; ?>
It will display in all pages header section.
add a comment |
If you declare something in default.xml , it will render in all the pages.
default.xml file looks like
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header">
<block class="ErSampleBlockTest" name="sample.test" before="-" template="Er_Sample::test.phtml"/>
</referenceContainer>
</body>
</page>
Create block file with necessary functions
In test.phtml
<?php echo "Welcome message in all magento pages!!!"; ?>
It will display in all pages header section.
If you declare something in default.xml , it will render in all the pages.
default.xml file looks like
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header">
<block class="ErSampleBlockTest" name="sample.test" before="-" template="Er_Sample::test.phtml"/>
</referenceContainer>
</body>
</page>
Create block file with necessary functions
In test.phtml
<?php echo "Welcome message in all magento pages!!!"; ?>
It will display in all pages header section.
edited Sep 17 '16 at 12:52
answered Sep 17 '16 at 11:05
Sivabupathy V R
545
545
add a comment |
add a comment |
Based off your input it sounds like you only want to change the styling?
If you want to make small styling changes you can extend the styling like so:
- Create this file -
app/design/frontend/Vendor/themename/Magento_Theme/web/css/source/_extend.less
- Add your styling here.
- Compile your styling, if you don't know how you can read about it here.
If you want to overwrite all the navigation styling then follow these steps:
- Copy this file into your theme -
vendor/magento/theme-frontend-blank/web/css/source/_navigation.less
->app/design/frontend/Vendor/themename/web/css/source/_navigation.less
- Make your styling changes in there
- Compile your styling, if you don't know how you can read about it here.
add a comment |
Based off your input it sounds like you only want to change the styling?
If you want to make small styling changes you can extend the styling like so:
- Create this file -
app/design/frontend/Vendor/themename/Magento_Theme/web/css/source/_extend.less
- Add your styling here.
- Compile your styling, if you don't know how you can read about it here.
If you want to overwrite all the navigation styling then follow these steps:
- Copy this file into your theme -
vendor/magento/theme-frontend-blank/web/css/source/_navigation.less
->app/design/frontend/Vendor/themename/web/css/source/_navigation.less
- Make your styling changes in there
- Compile your styling, if you don't know how you can read about it here.
add a comment |
Based off your input it sounds like you only want to change the styling?
If you want to make small styling changes you can extend the styling like so:
- Create this file -
app/design/frontend/Vendor/themename/Magento_Theme/web/css/source/_extend.less
- Add your styling here.
- Compile your styling, if you don't know how you can read about it here.
If you want to overwrite all the navigation styling then follow these steps:
- Copy this file into your theme -
vendor/magento/theme-frontend-blank/web/css/source/_navigation.less
->app/design/frontend/Vendor/themename/web/css/source/_navigation.less
- Make your styling changes in there
- Compile your styling, if you don't know how you can read about it here.
Based off your input it sounds like you only want to change the styling?
If you want to make small styling changes you can extend the styling like so:
- Create this file -
app/design/frontend/Vendor/themename/Magento_Theme/web/css/source/_extend.less
- Add your styling here.
- Compile your styling, if you don't know how you can read about it here.
If you want to overwrite all the navigation styling then follow these steps:
- Copy this file into your theme -
vendor/magento/theme-frontend-blank/web/css/source/_navigation.less
->app/design/frontend/Vendor/themename/web/css/source/_navigation.less
- Make your styling changes in there
- Compile your styling, if you don't know how you can read about it here.
answered Sep 18 '17 at 16:04
Ben Crook
8,6622172
8,6622172
add a comment |
add a comment |
I may be late to give an answer for this question. But as a beginner of magento, I have the same problem as yours.
I have done it up to some extent and like to share the way I have done it.
1) I first create the basic layout structure of the header, using content tags in default.xml file
I placed this in the referenceContainer name="header.container" tags in default.xml file. The reason is, navigation bar goes to the header section.
2) Then I have created a phtml file in magento, which includes the content of the navigation bar. This should be in the Magento_Theme module(Magento_Theme module is a customized module of the module_theme in vendor folder. This customized module should be in, app->design->frontend->vendor->yourtheme->Magento_Theme)
3) After that, call this phtml file using a in between the layout structure where you want to place the nav bar.
e.g:block class="MagentoFrameworkViewElementTemplate" name="header.nav.section" template="Magento_Theme::custom/head_navbar.phtml" before="-"
Here I have created a head_navbar.phtml file which contains the content of nav bar
Hope this will help you.
add a comment |
I may be late to give an answer for this question. But as a beginner of magento, I have the same problem as yours.
I have done it up to some extent and like to share the way I have done it.
1) I first create the basic layout structure of the header, using content tags in default.xml file
I placed this in the referenceContainer name="header.container" tags in default.xml file. The reason is, navigation bar goes to the header section.
2) Then I have created a phtml file in magento, which includes the content of the navigation bar. This should be in the Magento_Theme module(Magento_Theme module is a customized module of the module_theme in vendor folder. This customized module should be in, app->design->frontend->vendor->yourtheme->Magento_Theme)
3) After that, call this phtml file using a in between the layout structure where you want to place the nav bar.
e.g:block class="MagentoFrameworkViewElementTemplate" name="header.nav.section" template="Magento_Theme::custom/head_navbar.phtml" before="-"
Here I have created a head_navbar.phtml file which contains the content of nav bar
Hope this will help you.
add a comment |
I may be late to give an answer for this question. But as a beginner of magento, I have the same problem as yours.
I have done it up to some extent and like to share the way I have done it.
1) I first create the basic layout structure of the header, using content tags in default.xml file
I placed this in the referenceContainer name="header.container" tags in default.xml file. The reason is, navigation bar goes to the header section.
2) Then I have created a phtml file in magento, which includes the content of the navigation bar. This should be in the Magento_Theme module(Magento_Theme module is a customized module of the module_theme in vendor folder. This customized module should be in, app->design->frontend->vendor->yourtheme->Magento_Theme)
3) After that, call this phtml file using a in between the layout structure where you want to place the nav bar.
e.g:block class="MagentoFrameworkViewElementTemplate" name="header.nav.section" template="Magento_Theme::custom/head_navbar.phtml" before="-"
Here I have created a head_navbar.phtml file which contains the content of nav bar
Hope this will help you.
I may be late to give an answer for this question. But as a beginner of magento, I have the same problem as yours.
I have done it up to some extent and like to share the way I have done it.
1) I first create the basic layout structure of the header, using content tags in default.xml file
I placed this in the referenceContainer name="header.container" tags in default.xml file. The reason is, navigation bar goes to the header section.
2) Then I have created a phtml file in magento, which includes the content of the navigation bar. This should be in the Magento_Theme module(Magento_Theme module is a customized module of the module_theme in vendor folder. This customized module should be in, app->design->frontend->vendor->yourtheme->Magento_Theme)
3) After that, call this phtml file using a in between the layout structure where you want to place the nav bar.
e.g:block class="MagentoFrameworkViewElementTemplate" name="header.nav.section" template="Magento_Theme::custom/head_navbar.phtml" before="-"
Here I have created a head_navbar.phtml file which contains the content of nav bar
Hope this will help you.
edited Feb 26 '18 at 6:01
answered Feb 26 '18 at 5:56
Kash
12
12
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f136715%2fcreating-a-custom-navigation-bar%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