Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to implement custom blog pagination

By
Md. Tanzilul Hasan Khan
on 11/21/16, 10:59 PM 131 views

I am customizing the latest blog page. There I need to show highest 9posts on one page, if the number of posts are greater then they will go to next page. On website shop I saw it called website.pager template:

<template id="pager" name="Pager">    
<ul t-if="pager['page_count'] > 1" t-attf-class="#{ classname or '' } pagination" t-att-style="style or None">
<li t-att-class=" 'disabled' if pager['page']['num'] == 1 else None ">
<a t-att-href=" pager['page_previous']['url'] if pager['page']['num'] != 1 else None">Prev</a>
</li>
<t t-foreach="pager['pages']" t-as="page">
<li t-att-class=" 'active' if page['num'] == pager['page']['num'] else None ">
<a t-att-href="page['url']" t-raw="page['num']"></a>
</li>
</t>
<li t-att-class=" 'disabled' if pager['page']['num'] == pager['page_count'] else None ">
<a t-att-href="pager['page_next']['url'] if pager['page']['num'] != pager['page_count'] else None">Next</a>
</li>
</ul>
</template>

How can I implement such pagination on website blog?

PLEASE. DELETE THIS POST.

Md. Tanzilul Hasan Khan
on 11/21/16, 11:11 PM
0
Tech Support
On 11/23/16, 10:56 AM

There is pagination on the blog page too. It paginates after 20 posts. You'll see <t t-call="website.pager"> is also used here.

I need to show 9posts per page. I have found the base code where 20 is written, but I am unable to inherit that in my module.

Md. Tanzilul Hasan Khan
on 11/23/16, 11:46 AM

What if you duplicated the module, gave it a different name "website_blog_custom" and changed the _blog_post_per_page = 9? Kind of a hacky way of doing it, but maybe this will work for you?

Tech Support
on 11/23/16, 11:52 AM

I have inherited that class of the controller. Now it works. Thanks.

Md. Tanzilul Hasan Khan
on 11/25/16, 1:19 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/21/16, 10:59 PM
Seen: 131 times
Last updated: 11/25/16, 1:19 AM