[IMP] website: extracted language selector in its own template

It is a technical part of the website, it actually acts like a "Language Widget", I don't see any good reason to not extract it into its own template.
I needed this for a designer who wanted to move the language selection elsewhere, and I realized it was not already in its own template. Worse, we already had a duplication of this content in our own module!
I need this in saas-6 to get rid of the actual third duplications of this content which exists in 8.0 (counting the theme).
This commit is contained in:
David Monjoie
2015-03-02 14:09:55 +01:00
parent a8a9265340
commit 1e8932f769
2 changed files with 20 additions and 29 deletions
+19 -14
View File
@@ -383,26 +383,31 @@
their performance.
</p>
</div>
<ul class="list-inline js_language_selector mt16" t-if="(request.website_multilang and len(languages) &gt; 1) or editable">
<li t-foreach="languages" t-as="lg">
<a t-att-href="url_for(request.httprequest.path + '?' + keep_query(), lang=lg[0])"
t-att-data-default-lang="editable and 'true' if lg[0] == website.default_lang_code else None">
<t t-esc="lg[1].split('/').pop()"/></a>
</li>
<li groups="base.group_website_publisher">
<t t-set="url_return" t-value="url_for('', '[lang]') + '?' + keep_query()"/>
<a t-attf-href="/web#action=base.action_view_base_language_install&amp;website_id=#{website.id}&amp;url_return=#{url_return}">
<i class="fa fa-plus-circle"/>
Add a language...
</a>
</li>
</ul>
<t t-call="website.language_selector"/>
</div>
</div>
</div>
</xpath>
</template>
<template id="language_selector">
<ul class="list-inline js_language_selector mt16" t-if="(request and request.website_multilang and len(languages) &gt; 1) or (website and editable)">
<li t-foreach="languages" t-as="lg">
<a t-att-href="url_for(request.httprequest.path + '?' + keep_query(), lang=lg[0])"
t-att-data-default-lang="editable and 'true' if website and lg[0] == website.default_lang_code else None">
<t t-esc="lg[1].split('/').pop()"/>
</a>
</li>
<li groups="base.group_website_publisher">
<t t-set="url_return" t-value="url_for('', '[lang]') + '?' + keep_query()"/>
<a t-attf-href="/web#action=base.action_view_base_language_install&amp;website_id=#{website.id if website else ''}&amp;url_return=#{url_return}">
<i class="fa fa-plus-circle"/>
Add a language...
</a>
</li>
</ul>
</template>
<template id="publish_management">
<div groups="base.group_website_publisher" t-ignore="true" class="pull-right css_editable_mode_hidden" t-att-style="style or ''">
<div t-attf-class="btn-group js_publish_management #{object.website_published and 'css_published' or 'css_unpublished'}" t-att-data-id="object.id" t-att-data-object="object._name" t-att-data-controller="publish_controller">
+1 -15
View File
@@ -20,21 +20,7 @@
</xpath>
<xpath expr="//header" position="replace"/>
<xpath expr="//footer" position="replace">
<ul class="list-inline js_language_selector mt16" t-if="(request and request.website_multilang and len(languages) &gt; 1) or (website and editable)">
<li t-foreach="languages" t-as="lg">
<a t-att-href="url_for(request.httprequest.path + '?' + keep_query(), lang=lg[0])"
t-att-data-default-lang="editable and 'true' if website and lg[0] == website.default_lang_code else None">
<t t-esc="lg[1].split('/').pop()"/>
</a>
</li>
<li groups="base.group_website_publisher">
<t t-set="url_return" t-value="url_for('', '[lang]') + '?' + keep_query()"/>
<a t-attf-href="/web#action=base.action_view_base_language_install&amp;website_id=#{website.id if website else ''}&amp;url_return=#{url_return}">
<i class="fa fa-plus-circle"/>
Add a language...
</a>
</li>
</ul>
<t t-call="website.language_selector"/>
</xpath>
</template>