Skip to Content
Menu
This question has been flagged

Hi,

I was trying to add to my Odoo website a cookie bar (according to EU law). I wanted to use one from http://www.primebox.co.uk/projects/jquery-cookiebar/ but unfortunately it doesn't work. I've edited <head> section as mentioned in Installing part.

Does anyone have information how can I enable this?

Also I wanted to make similar thing but with information about old webbrowser (I saw that Odoo needs a new ones to display website properly).

Avatar
Discard
Best Answer

Hi,

Not sure if you still have this issue, since it's been a while since you asked this question. But I was facing the same problem as you are and finally found out how to implement the cookiewarning in my website.

Basically what you want to do is write a template that inherits from website.layout. Write an xpath expression here with attribute expr="//head" and position="inside", in this xpath, just place your css, js and the document.reay function.

So your template should look something like this:

<template id="header_lang" inherit_id="website.layout">
  <xpath expr="//head" position="inside">
    <script type="text/javascript" src="https://code.jquery.com/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/xx_website_sale/static/src/css/jquery.cookiebar.css" />
    <script type="text/javascript" src="/xx_website_sale/static/src/js/jquery.cookiebar.js"/>
    <script type="text/javascript">
    $(document).ready(function(){
      $.cookieBar({
      });
    });
    </script>
  </xpath
</template>

Please upvote the answer if this helped you (:

Avatar
Discard
Author

Hi, thanks for the answer but I've already learned about Odoo website MVC model and learned how to add JS scripts / qweb templates and all that stuff. But maybe someone will need that answer ;)

Did you use the same approach I did, or did you do something completely else? I do my js like this now, but if there is a better way to do this, I'd like to know :)

Related Posts Replies Views Activity
1
May 23
7127
1
Jul 16
4002
1
Jun 23
2933
0
Jan 21
2708
2
Dec 19
8431