Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6701 มุมมอง

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.

คำตอบที่ดีที่สุด

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.

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?

ผู้เขียน

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
Importing articles to the blog แก้ไขแล้ว
2
มิ.ย. 22
3392
2
พ.ย. 21
3131
2
ก.พ. 16
4196
Odoo blog cover image not showing แก้ไขแล้ว
1
ก.ค. 24
7478
3
มิ.ย. 24
2681