Reputation: 85
Basically, I want to know if there is a way to inherit website.footer_default to wrap part of the contents inside a div.
To give a short example, if the initial template looks like this:
<template name="website.footer_default">
<div id="footer">
<content>
</div>
</template>
And I'd like to replace it with:
<template name="website.footer_default">
<div id="footer">
<div class="mynewdiv">
<content>
</div>
</div>
</template>
Is there a way to achieve that without having to copy/paste all the inside an xpath?
I also tried to inherit this template the qweb way, but the code doesn't seem to get executed.
Any ideas?
Upvotes: 2
Views: 1615
Reputation: 544
In Odoo 11 you can do this:
<template name="new_footer_default" inherit_id="website.footer_default">
<xpath expr="//div[@id='footer']" position="replace">
<div id="footer">
<div class="mynewdiv">$0</div>
</div>
</xpath>
</template>
$0 is the marker where the content of the replaced node is added. it has to be a used as a text node containing only $0 (no whitespaces or other text)
See https://www.odoo.com/documentation/11.0/reference/views.html (search for replace)
Upvotes: 1
Reputation: 85
I found a way to achieve this without having to rewrite everything, with one limitation: it only works on web templates.
The solution uses javascript (and the fact that Odoo website comes bundled with jquery) to wrap elements at runtime.
Here is how that looks codewise:
<template name="new_footer_default" inherit_id="website.footer_default">
<div id="footer" position="before">
<script>
$(document).ready(function(){
$('#footer>*').wrapAll('<div class='mynewdiv'/>');
});
</script>
</div>
</template>
Upvotes: 1
Reputation: 3378
This worked for me. Access the parent which contains the footer and replace it with your code wrapping the original code.
<openerp>
<data>
<template id="new_footer" inherit_id="website.layout">
<xpath expr="//footer" position="replace">
<footer>
<div class="mynewdiv">
<div id="footer_container">
</div>
</div>
</footer>
</xpath>
</template>
</data>
</openerp>
Upvotes: 0