Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6525 Lượt xem

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

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 18
6854
1
thg 5 25
10274
1
thg 4 24
2681
1
thg 2 23
2727
5
thg 2 24
24118