====== Layout ====== In this chapter, you will learn how to: - Create a custom header. - Create a custom footer. - Modify a standard template. - Add a copyright section. - Improve your website's responsiveness. Default ======= An Odoo page combines cross-page and unique elements. Cross-page elements are the same on every page, while unique elements are only related to a specific page. By default, a page has two cross-page elements, the header and the footer, and a unique main element that contains the specific content of that page. .. code-block:: xml
Any Odoo XML file starts with encoding specifications. After that, you must write your code inside an `` tag. .. code-block:: xml ... .. note:: Using precise file names is important to find information through all modules quickly. File names should only contain lowercase alphanumerics and underscores. Always add an empty line at the end of your file. This can be done automatically by configuring your IDE. XPath ===== XPath (XML Path Language) is an expression language that enables you to navigate through elements and attributes in an XML document easily. XPath is used to extend standard Odoo templates. A view is coded the following way. .. code-block:: xml .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Attribute - Description * - id - ID of the modified view * - inherited_id - ID of the standard view * - name - Human-readable name of the modified view For each XPath, you modify two attributes: **expression** and **position**. .. example:: .. code-block:: xml :caption: ``/website_airproof/views/website_templates.xml`` This XPath adds a welcome message right before the page content. .. warning:: Be careful when replacing default elements' attributes. As your theme extends the default one, your changes will take priority over any future Odoo update. .. note:: - You should update your module every time you create a new template or record. - *XML IDs* of inheriting views should use the same *ID* as the original record. It helps to find all inheritance at a glance. As final *XML IDs* are prefixed by the module that creates them, there is no overlap. Expressions ----------- XPath uses path expressions to select nodes in an XML document. Selectors are used inside the expression to target the right element. The most useful ones are listed below. .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Descendent selectors - Description * - / - Selects from the root node. * - // - Selects nodes in the document from the current node that matches the selection no matter where they are. .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Attribute selectors - Description * - \* - Selects any XML tag. `*` can be replaced by a specific tag if the selection needs to be more precise. * - \*[@id="id"] - Selects a specific ID. * - \*[hasclass("class")] - Selects a specific class. * - \*[@name="name"] - Selects a tag with a specific name. * - \*[@t-call="t-call"] - Selects a specific t-call. Position -------- The position defines where the code is placed inside the template. The possible values are listed below: .. list-table:: :header-rows: 1 :stub-columns: 1 :widths: 20 80 * - Position - Description * - replace - Replaces the targeted node with the XPath content. * - inside - Adds the XPath content inside the targeted node. * - before - Adds the XPath content before the targeted node. * - after - Adds the XPath content after the targeted node. * - attributes - Adds the XPath content inside an attribute. .. example:: This XPath adds a `
` before the `