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 add snippet with CSS and JS?

By
biligsaikhan
on 11/13/14, 10:41 PM 2,105 views

i have created a snippet but the css and js are not being called. 

this is in my snippet.xml

<section class="oe_snippet_body fancybox">
                        <div class="col-md-3">
                            <div class="post-thumbnail element">
                                <img src="/website_fancybox/static/img/Moon.jpg"/> 
                                <a data-fancybox-group="gallery" href="/website_fancybox/static/img/Moon.jpg"
                                class="element-lightbox fancybox">
                                <i class="fa fa-search-plus"></i></a>
                            </div>
                        </div>
                    </section>

and i tried to call the css and js using assets.xml

<openerp>
    <data>

        <template id="javascripts_head" inherit_id="website.layout">
            <xpath expr="//head" position="inside">
              <link href="/website_fancybox/static/css/bootstrap.min.css" rel="stylesheet" type="text/less"/>
              <link href="/website_fancybox/static/css/style.css" rel="stylesheet" type="text/less"/>
              <link href="/website_fancybox/static/css/jquery.fancybox.css" rel="stylesheet" type="text/less"/>
              <script type="text/javascript" src="/website_fancybox/static/src/js/fboxscript.js"></script>
              <script type="text/javascript" src="/website_fancybox/static/src/js/jquery.fancybox.js"></script>
              <script type="text/javascript" src="/website_fancybox/static/src/js/jquery-1.10.1.min.js"></script>
            </xpath>
        </template>

    </data>
</openerp>

how do i make this work. i wanted the image to show in col-md-3 size not its original size. also the js would bring up modal box. 

0
Haojun Zou
On 6/29/15, 6:26 AM

You need a template that inherit "website.assets_editor", something like that:

<template id="custom_css_and_js" inherit_id="website.assets_editor" name="Custom CSS and JS">

    <xpath expr="//link[last()]" position="after">

        <!-- your custom css goes here -->

    </xpath>

    <xpath expr="//script[last()]" position="after">

        <!-- your custom javascript goes here -->

    </xpath>

</template>

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: 11/13/14, 10:41 PM
Seen: 2105 times
Last updated: 6/29/15, 6:26 AM