Odoo Help


Theming: adding HTML in just one page

Bruno Matthys
on 3/3/15, 6:39 AM 2,315 views

Thanks to some very valuable input from this forum I am making good progress on theming.

Now I would like to show a block of HTML on the home page only which looks like:

<template id="x_mytheme.home" name="My Home" page="True">
        <t t-call="x_mytheme.layout">
            <div id="maincol">

For testing purposes I'm using a copy of website.layout which I'm editing:

<template id="x_mytheme.layout" name="My Layout">&lt;!DOCTYPE html&gt;
<div id="content-top" class="row">

The HTML block needs to show below #content-top; I know this works when I inherit my layout:
<xpath expr="//div[@id='content-top']" position="after">

This affects every page that calls my layout though. How can I do this when this layout is called inside another view with t-call?


Btw, any idea how I can add this code below to source? Am I right in presuming it is stripped from the source before building the HTML?
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>

Is there any info on how Odoo handles this kind of conditional statements?


Bruno Matthys
On 3/4/15, 11:57 AM

I could solve this by using an if condition:

<div t-if="condition"> <p>Test</p> </div>

where condition is a check that the current view using the layout is the home page. But I can't figure out how to do that.


EDIT: I found it

I do this in my main layout:

<t t-if="xmlid == 'website.home'">
     <t t-call="x_mytheme.section"/>

I tried with xml_id as I found that in the ORM guide, is there a way to have all these available variables or where can I learn more about them?


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/3/15, 6:39 AM
Seen: 2315 times
Last updated: 3/16/15, 8:10 AM