跳至内容
菜单
此问题已终结
1 回复
6541 查看

Is it possible to override a menu item to redirect to different url?

I need to change the url of the contactus menu item.

形象
丢弃
最佳答案

Hi,

Either you can do it from the front end or by the code. If you are doing from the front end, see the below image,


Navigate to Contents -> Edit Menu -> Select the menu and clicking the edit button you can change the URL.


If you want to do the same from code,  see the original code for the menu contacts,

<record id="menu_contactus" model="website.menu">
<field name="name">Contact us</field>
<field name="url">/contactus</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">60</field>
</record>


here what you have to do is that, in your module, update the code like this,

<record id="website.menu_contactus" model="website.menu">
<field name="url">/customurl</field>
</record>


Thanks

形象
丢弃
编写者

I want to do it in the code. I found the original code. Tried your code but it doesn't work. It still redirects to /page/contactus and not to /contact-us.

编写者

It worked from the front end, but I still need to make this in the code so it gets done on module install or upgrade.

相关帖文 回复 查看 活动
1
3月 18
6862
1
5月 25
10289
1
4月 24
2809
1
2月 23
2826
5
2月 24
24152