Odoo Help

Welcome!

This community 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.

1

Theming: adding HTML in just one page

By
Bruno Matthys
on 3/3/15, 6:39 AM 1,573 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">
                ...[html]...
     
       </div>
</template>

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;
    ...[html]...
    
<div id="content-top" class="row">
        ....[html]...
    </div>
</template>

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">
...
</xpath>

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>
<![endif]-->

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

Cheers
Bruno

0
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"/>
 </t>

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?

Thanks

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!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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