콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
7550 화면

I have a qweb setup like this: 

file 'a.xml':

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="templatename">
        ...          </t>     
</templates>
file 'b.xml':

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-extend="templatename">
        *** CONTENT TO REPLACE ***          
    </t>     
</templates>
How do I replace that content?
I tried using both the deprecated t-extends and the up-to-date t-inherit methods: 
<t t-extend="templatename">
    <xpath expr="..." position="replace">
        *** REPLACEMENT CONTENT ***
    </xpath>
</t>

<t t-inherit="moduleoftemplatename.templatename" t-inherit-mode="extension"> <xpath expr="..." position="replace"> *** REPLACEMENT CONTENT *** </xpath> </t>

But neither of these work, as these inherit the template specified in 'a.xml', so xpath can't find the content from 'b.xml' it's looking for. 
How can I solve this given that I can't change content in 'a.xml' or 'b.xml'?

아바타
취소
베스트 답변

Hi, 

Here is a simple example: 

<t t-extend="OrderReceipt">
<t t-jquery=".pos-receipt-order-data" t-operation="append">
<t t-if="receipt.l10n_fr_hash !== false">
<div style="word-wrap:break-word;"><t t-esc="receipt.l10n_fr_hash"/></div>
</t>
</t>
</t>


OrderReceipt is the name of a template. 

pos-receipt-order-data is a class of an element inside the temp OrderReceipt
then we choose t-operation="append".

In your case, you do the same but with t-operation="replace"

Hope this helps.
Regards.

아바타
취소
작성자

I think you might have understood what I need. The way your example would work is that it would replace the entire 'pos-receipt-order-data' element, which is not what I need.

Porting my problem to your solution, What I need is ideally replacing only the '<div style="word-wrap:break-word;">'. The original template (OrderReceipt) should not be altered in any way.

I would also be okay with replacing the entire '<t t-extend="OrderReceipt">...</t>' altogether, but I can't find a way to inherit this extension.

Hello,

my example is just to show you how to replace since in your question you mentioned that you do not know how to do it. The answer to that is simple with t-operation="replace". this answers your Question dude.

We don't use Xpath in Qweb :)

Now since you know how to do replace operations, it's up to you to get the element you want to replace.

Good luck!

관련 게시물 답글 화면 활동
2
12월 22
22982
Qweb Inheritance 해결 완료
3
11월 19
7834
1
1월 17
4375
2
1월 24
1427
2
12월 21
22486