How it works...

To enable SEO on each record of the model, you will need to inherit the website.seo.metadata mixin in your model. This will add a few fields and methods in the library.book model. These fields and methods will be used from the website to store separate data for each book.

If you want to see fields and methods for the SEO mixin, search for the website.seo.metadata model in the /addons/website/models/website.py file.

All SEO related code is written in the website.layout and it gets all the SEO meta information from the recordset passed as main_object. Consequently, in step 2, we have passed a book object with the main_object key, so the website layout will get all SEO information from the book. If you don't pass the main_object from the controller, then the template recordset will be passed as main_object, and that's why you were getting the same SEO data in all books.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset