CMS Development

MattOnce
投稿者

Pagination issue for listing page that only contains one topic

解決

I am trying to edit the blog listing page template so my main blog listing page only displays posts with the "Featured" tag.

 

I have added the lines 

{% for topic in content.topic_list %}
{% if topic.name == 'Featured' %} 

just below the  {% for content in contents %}  line of code, and that works correctly.

 

My problem is that the pagination still seems to be using the total page number based on all the blog posts, not just this subset. 

The result is that I have pages 1 to 5 displaying in the pagination navigation, but pages 4 anf 5 are empty, as I only have 3 pages worth of "Featured" posts.

 

How can I edit the pagination so that it bases the number of pages on the "Featured" topic?

0 いいね!
1件の承認済みベストアンサー
Kevin-C
解決策
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

Pagination issue for listing page that only contains one topic

解決

Hey @MattOnce 

The blog_recent_tag_posts function might be worth a try. I'd bet you could create a module and drop it on a webpage to create this repository of filtered blog posts.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

元の投稿で解決策を見る

4件の返信
Kevin-C
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

Pagination issue for listing page that only contains one topic

解決

Hey @MattOnce 

 

So to my knowledge you cannot modify the types of content that hubspot pulls when getting the blogs. At least not using the standard blog template markup. That means pagination isn't the issue. You'll need to rethink how you're getting or even storing the blog posts.

 

An option might be to export the blog, separate the posts in a spreadsheet, then upload to two different blogs. Or even unpublishing all non-featured posts.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
MattOnce
投稿者

Pagination issue for listing page that only contains one topic

解決

Thanks @Kevin-C 

 

What I am trying to do is a little hacky, admittedly. I want to have posts that are published and viewable, but I don't want them to be shown on the listing page. So separate blogs or unpublishing them is not an option. 

 

Is there a better way to go about achieving this?

0 いいね!
Kevin-C
解決策
名誉エキスパート | Solutions Partner
名誉エキスパート | Solutions Partner

Pagination issue for listing page that only contains one topic

解決

Hey @MattOnce 

The blog_recent_tag_posts function might be worth a try. I'd bet you could create a module and drop it on a webpage to create this repository of filtered blog posts.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
MattOnce
投稿者

Pagination issue for listing page that only contains one topic

解決

Thanks once again, @Kevin-C . I have come across this function in my research, and I think you're right - I could probably use it to achieve the result I'm looking for.

0 いいね!