I am trying to create a Landing Page for my Magento site. I created this by creating a new CMS page through Admin/Content/Pages. I'm wondering if I can add a custom sticky navigation menu to this page? This custom sticky navigation will be different and in addition to my default website header.
1 Answer
Yes, you'll have to define a file in frontend/layout with name "default.xml" which actually lets you add custom things in headers/footers. See the code below: In component you give your JS file(if you want one for making it sticky) while in template you'll use html to show whatever you want in the header. P.S: See the difference between "templates" and "template" folder.Both are different. Hope it helps!
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <css src="Vendor_Module::css/vendor.cssfilename.css"/> </head> <body> <referenceContainer name="header.container"> <block class="Vendor\Module\Block\File" name="name" template="Vendor_Module::"path_to_frontend_templateS"/file.phtml"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> <item name="vendor-module-name" xsi:type="array"> <item name="component" xsi:type="string">Vendor_Module/js/view/js_file</item> <item name="config" xsi:type="array"> <item name="template" xsi:type="string">Vendor_Module/"path_to_frontend_templatE"/html_file</item> </item> </item> </item> </argument> </arguments> </block> </referenceContainer> </body> </page>