Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5235 Widoki

I want to serve blog posts without the BLOG_NAME-ID part of the URL.

For example right now my blog posts have the following URL:

example.com/blog/NAME-1/post-slug

I want to remove the NAME-1 part of the URL. It's totally unnecessary for me as I don't need multiple blogs.

So I guess I have to somehow override the WebsiteBlog.blog_post() method and use another @http.route decoration? Can you please point me to what's the correct way of doing this?

Awatar
Odrzuć
Autor Najlepsza odpowiedź

OK, and what should I do in that controller? Subclass WebsiteBlog and call super.blog_post() or something else? Also, where are these XML files I need to change? Please be more specific as I'm just starting to use Odoo.

Awatar
Odrzuć

Controller:

create new controller /post/POST-NAME

browse post-name record and rest logic you can bring from default blog post controller.

XML

use existing post template and if need inherit default controller url to new controller url. That's it all you need to know

Najlepsza odpowiedź

Hi,

If you remove blog name from URL then you lost multi blog manage functionality. So we assume that you have only 1 blog and all post will under this 1 blog. We suggest you to create new controller like /post/POST-NAME . This is much easy to handle it. Moreover you need update url in your XML templates.

Thanks.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
sty 20
4386
2
wrz 22
1726
2
cze 22
3376
0
lis 21
2323
2
lis 21
3110