This question has been flagged
2 Replies
10582 Views

Hello all,

I'm searching the right way to implement Facebook open graph meta tag on the product page of my shop on the front-end. 

Somebody has successfully done it?

Would you have some tips?

Thanks


UPDATE #1

For example, I would search an example on how to fill dynamically those <meta> in a page like this product page : http://intimeetvilain.com/shop_iv/product/advanced-waterproof-jack-rabbit-1850

    <template id="website_lapagept.facebook_open_graph_tags_iv">

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

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

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

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

    </template>


UPDATE #2

When I inspect the source code on this page you are reading, I see that all the open graph <meta> are well filled. Where could I find the code to do the same thing on my odoo?


UPDATE #3

When we click on the « share » button just below, four buttons appear. How could I implement those 4 buttons myself on my odoo? Where is the code?

Avatar
Discard

What do you mean by Facebook Open Graph ? Is it means that you want to add a button of Facebook to share that product page into Facebook ? In this link (https://www.odoo.com/blog/odoo-news-5/post/top-apps-themes-in-odoo-store-314) there is 4 buttons ....Please confirm that do you want exactly like that ?

Author Best Answer

Here is our answer. We have found it in the Odoo 9 code. It is surely not the best code, but it works for our needs at this moment. Thanks

<?xml version="1.0" encoding="utf-8"?>

        <openerp>

                <data>

                        <template id="website_lapagept.website_layout_iv" name="Main layout - IV">&lt;!DOCTYPE html&gt;

                                <html t-att-lang="lang and lang.replace('_', '-')"

                                        t-att-data-website-id="website.id if editable and website else None"

                                        t-att-data-editable="'1' if editable else None"

                                        t-att-data-translatable="'1' if translatable else None"

                                        t-att-data-view-xmlid="xmlid if editable else None"

                                        t-att-data-main-object="repr(main_object) if editable else None"

                                        t-att-data-oe-company-name="res_company.name">

                            <head>

                                    <meta charset="utf-8" />

                                    <t t-if="main_object and 'website_meta_title' in main_object and not title">

                                            <t t-set="title" t-value="main_object.website_meta_title"/>

                                    </t>

                                    <t t-if="main_object and 'name' in main_object and not title and not additional_title">

                                            <t t-set="additional_title" t-value="main_object.name"/>

                                    </t>

                                    <t t-if="not title">

                                            <t t-set="title"><t t-if="additional_title"><t t-raw="additional_title"/> | </t><t t-esc="(website or res_company).name"/></t>

                                    </t>

                                    <meta name="viewport" content="initial-scale=1"/>

                                    <meta name="description" t-att-content="main_object and 'website_meta_description' in main_object

and main_object.website_meta_description or website_meta_description"/>

                                    <meta name="keywords" t-att-content="main_object and 'website_meta_keywords' in main_object

and main_object.website_meta_keywords or website_meta_keywords"/>

                                    <meta name="generator" content="Odoo"/>

                        <!-- OpenGraph tags for Facebook sharing -->

                        <meta property="og:title" t-att-content="additional_title" />

                        <meta property="og:site_name" t-att-content="res_company.name" />

                        <meta property='og:url' t-att-content="request.httprequest.url_root+request.httprequest.path[1:end]"/>

                        <!-- OpenGraph pour le forum -->

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

                                <t t-set="og_description" t-value="main_object.plain_content[0:500]"/>

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

                                <meta property='og:image' t-att-content="request.httprequest.url_root+'logo.png'"/>

                        </t>

                        <!-- OpenGraph pour les produits avec une description de vente -->

                        <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>

                        <!-- OpenGraph pour les produits sans description de vente mais une description -->

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

                                 <t t-set="og_description" t-value="main_object.description"/>

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

                        </t>

                        <!-- OpenGraph pour les images de produits -->

                        <t t-if="main_object and 'image' in main_object">

                                <meta property='og:image' t-att-content="request.httprequest.host_url+website.image_url(product, 'image_big', None if product_image_big else '300x300')" />

                        </t>

Avatar
Discard