默认¶
Odoo会根据您安装的应用程序自动生成一些基本的菜单项。例如,网站应用程序会在主菜单中添加两项。这些项链接到页面,页面也会自动生成。
删除默认菜单项。
/website_airproof/data/menu.xml¶<!-- Delete: Contact us and Shop menu items -->
<delete
model="website.menu"
search="[('url','in', ['/contactus', '/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/static/src/website_builder/mega_menu_option.xml¶<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="website_airproof.MegaMenuOption" t-inherit="website.MegaMenuOption" t-inherit-mode="extension">
<xpath expr="//BuilderSelect[@id="'mega_menu_template_opt'"]" position="inside">
<BuilderSelectItem
title.translate="Airproof"
actionParam="{
view: `website_airproof.s_mega_menu_airproof`,
templateClass: 's_mega_menu_airproof',
}">
<Img class="'w-75 mx-auto my-3'" src="'/website_airproof/static/src/img/wbuilder/template-header-opt.svg'" />
</BuilderSelectItem>
</xpath>
</t>
</templates>