Skip to Content

Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
57 Views

Please πŸ˜ͺ could someone help me customize Odoo website header by coding not from the website editor


Avatar
Discard

Hii,

Create or Use a Custom Module

If you don’t already have one, create a custom module called (for example) custom_website_header.

Folder structure:

custom_website_header/ β”œβ”€β”€ __init__.py β”œβ”€β”€ __manifest__.py β”œβ”€β”€ static/ β”‚ └── src/ β”‚ └── css/ β”‚ └── header.css β”œβ”€β”€ views/ β”‚ └── header_template.xml

Inherit the Header Template

Odoo uses website.layout β†’ website.header for the main header.

Here’s how toΒ extend or replace part of the headerΒ in views/header_template.xml:

<?xml version="1.0" encoding="UTF-8"?> <odoo> <template id="custom_website_header" inherit_id="website.header" priority="20"> <!-- Example: Replace social media icons section --> <xpath expr="//div[contains(@class, 'o_header_social')]" position="replace"> <div class="o_header_social"> <!-- Add your own icons or links here --> <a href="https://facebook.com" target="_blank">FB</a> <a href="https://linkedin.com" target="_blank">LinkedIn</a> <a href="https://instagram.com" target="_blank">Insta</a> </div> </xpath> <!-- Example: Add a phone number above the menu --> <xpath expr="//header" position="inside"> <div class="my-top-bar text-center py-1 bg-warning text-dark"> <span>πŸ“ž +971 525585292 | βœ‰οΈ yahyasbini@gmail.com</span> </div> </xpath> </template> </odoo>

changes as your requiremnts

Add Custom CSSΒ 
Create static/src/css/header.css and style your changes:

.my-top-bar { font-weight: bold; font-size: 14px; } .o_header_social a { margin: 0 8px; color: #fff; }

add css as per your design

update __manifest__.py

{ 'name': 'Custom Website Header', 'category': 'Website', 'version': '16.0.1.0.0', 'depends': ['website'], 'data': [ 'views/header_template.xml', ], 'assets': { 'web.assets_frontend': [ 'custom_website_header/static/src/css/header.css', ], }, 'installable': True, }

i hope it is use full

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!