默认¶
Odoo会根据您安装的应用程序自动生成一些基本的菜单项。例如,网站应用程序会在主菜单中添加两项。这些项链接到页面,页面也会自动生成。
删除默认菜单项。
/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>
选项
使用以下代码为您的新自定义巨幅菜单在网站构建器中添加选项。
/website_airproof/data/presets.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>