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.

0

How to attrib variable value to a tag attribute?

By
Pascal Tremblay
on 9/23/15, 8:16 AM 826 views

Hello there,

I'm searching the way to directly attrib a variable value to an attribute of a tag :

    <template id="website_lapagept.facebook_open_graph_tags_iv">

        <t t-set="variable" t-value="FFRGRGRGFGFGFBVFVFGGFGFGFVF" />

        <meta property="og:title" content="" />

        <meta property="og:type" content=variable />  (IT DOESN'T WORK)

    </template>


Could you help me please?


UPDATE #1

ref : https://www.odoo.com/fr_FR/forum/help-1/question/append-value-to-attribute-in-qweb-template-76953

If I inherit the above template, I can change the « content » attribute value. But it is not what I want. Can we do this without inheritance and without xpath?

    <template id="website_lapagept.facebook_open_graph_title_iv" inherit_id="website_lapagept.facebook_open_graph_tags_iv" name="Facebook open graph description - IV">

            <xpath expr='//meta[@property="og:title"]' position="attributes">

                    <attribute name="content">Intime &amp; vilain</attribute>

            </xpath>

    </template>


UPDATE #2

This new way doesn't work too :

    <template id="website_lapagept.facebook_open_graph_tags_iv">

        <t t-set="variable" t-value="FFRGRGRGFGFGFBVFVFGGFGFGFVF" />

        <meta t-att="{'property':'og:type', 'content':variable}" />

</template>


UPDATE #3

This new way doesn't work too : 

    <template id="website_lapagept.facebook_open_graph_tags_iv">

        <t t-set="variable" t-value="FFRGRGRGFGFGFBVFVFGGFGFGFVF" />  

        <meta property="og:type" t-att-content="variable" />

    </template>

0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 9/25/15, 12:55 PM

This one works. It was what we needed.

<t t-if="main_object and 'description_sale' in main_object and main_object.description_sale">

    <t t-set="og_description_sale" t-value="main_object.description_sale"/>

    <meta property="og:description" t-att-content="og_description_sale" />

</t>

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: 9/23/15, 8:16 AM
Seen: 826 times
Last updated: 9/25/15, 12:55 PM