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

Hello Odoo community?

I was wondering if there is a way how i could change url of the blog post?

Any ideas and examples would be appreciated!

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

The website_url field determines the URL of each Blog Post.

It is defined in the model website.published.mixin as a functional field using the function _website_url to get the value.

Functional fields are managed by Odoo, and not designed to be edited by users.

The blog.post model overrides _website_url and provides a new function:

    def _website_url(self, cr, uid, ids, field_name, arg, context=None):
res = super(BlogPost, self)._website_url(cr, uid, ids, field_name, arg, context=context)
for blog_post in self.browse(cr, uid, ids, context=context):
res[blog_post.id] = "/blog/%s/post/%s" % (slug(blog_post.blog_id), slug(blog_post))
return res

So you are unable to change the Blog Post URL without overriding this function.

Note: slug is a Python function that "slugifies" strings (returns a safe unicode human readable version of string suitable for forming a URL)



Ảnh đại diện
Huỷ bỏ

So you are unable to change the Blog Post URL without overriding this function...
Not really, the url is defined by routes! So if you change routes (used for dispatch) you need to change this function according to the new routes. This function is used usually to link the backend and the frontend.

@Jeremy Kersten - you are welcome to post your own answer.

Câu trả lời hay nhất

hello

output code top for me:  

Error message:

404: Not Found
please help me.
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 25
1871
3
thg 8 19
12301
1
thg 3 16
4663
2
thg 9 22
1772
0
thg 11 21
2393