デフォルト¶
Odoo は、インストールしたアプリに応じて、いくつかの基本的なメニュー項目を自動的に生成します。 たとえば、ウェブサイトアプリはメインメニューに2つの項目を追加します。これらの項目はページにリンクされ、自動的に作成されます。
デフォルトのメニュー項目を削除します。
/website_airproof/data/menu.xml
¶<!-- Contact us -->
<delete model="website.menu" search="[('url','in', ['/', '/contactus']),
('website_id', '=', 1)]"/>
<!-- Shop -->
<delete model="website.menu" search="[('url','in', ['/', '/shop']),
('website_id', '=', 1)]"/>
新しいウィンドウ¶
新しいタブでリンクの URL を開きます。
<record id="..." model="website.menu">
<field name="new_window" eval="True"/>
</record>
外部リンク¶
外部ウェブサイトへのリンクを追加します。
<record id="..." model="website.menu">
<field name="url">https://www.odoo.com</field>
</record>
アンカー¶
ページの特定のセクションにリンクします。
<record id="..." model="website.menu">
<field name="url">/about-us#our-team</field>
</record>
カスタムテンプレート¶
独自のテンプレートを作成し、リストに追加します。
レイアウト
/website_airproof/views/website_templates.xml
¶<template id="s_mega_menu_airproof" name="Airproof" groups="base.group_user">
<section class="s_mega_menu_airproof o_cc o_cc1 pt40">
<!-- Content -->
</section>
</template>
Option
次のコードを使用して、ウェブサイトビルダーで新しいカスタムメガメニューのオプションを追加します。
/website_airproof/views/snippets/options.xml
¶<template id="snippet_options" inherit_id="website.snippet_options" name="Airproof - Mega Menu Options">
<xpath expr="//*[@data-name='mega_menu_template_opt']/*" position="before">
<t t-set="_label">Airproof</t>
<we-button t-att-data-select-label="_label"
data-select-template="website_airproof.s_mega_menu_airproof"
data-img="/website_airproof/static/src/img/builder/header_opt.svg"
t-out="_label"/>
</xpath>
</template>