CMS Development

EricPowell-SR
Membre

Sort Blog Listing by Topic

When pulling the blog listing, I want it to list the blog articles in order of the first topic of a blog post (either alphabetically or in a custom order). So far I've tried this, but realize this is not going to work because "content.topic_list" is only going to work within the content loop. What does work?

{% for content in contents|sort(False, False, content.topic_list) %}
    <div class="post-item">
        Post item markup that renders with each iteration.              
    </div>
{% endfor %}     

See https://www.springboardretail.com/integrations

2 Réponses
krishangtechn
Membre

Sort Blog Listing by Topic

@EricPowell-SR ,

 

Not sure your point 100% but I think you are trying to get latest post topic by alphabet index right.

 

I did recently using the latest post article with the latest date etc so I think will share with you if something will helpful. 

 

For more request to share brief detailed on the private window so I can help you further

 

{% set rec_posts = blog_recent_posts('12345566', 1) %}
{% for rec_post in rec_posts %}
<div class="blog-latest-post-hero-wrap" style="background-image:url('{{ module.background_hero_image.src }}')">
<div class="page-center">
<div class="blog-latest-post-inner">
<div class="blog-latest-post-feature-image">
<img src="{{ rec_post.featured_image }}">
</div>
<div class="blog-latest-post-caption">
<div class="blog-latest-post-date">
<a href="javascript&colon;;">{{ rec_post.publish_date|datetimeformat('%B %e, %Y')|capitalize }}</a>
</div>
<div class="blog-latest-post-title">
<h1>{{ rec_post.name }}</h1>
</div>
<div class="blog-latest-post-text">
<p> {{ rec_post.post_body|trim|striptags|truncate(150,'') }} </p>
</div>
<div class="blog-latest-post-read-more">
<a href="{{ rec_post.absolute_url }}">abc</a>
</div>
</div>
</div>
</div>
</div>
{% endfor %}

 

PS: If you like the solution then kindly click on mark as solution and upvote will be appreciated

Thanks & Regards,

Ramesh Gosiya

Krishang Technolab

EricPowell-SR
Membre

Sort Blog Listing by Topic

Thank you for your reply. This is not really what I am looking for. I would like to list all blog posts, but have them sorted in alphabetical order by blog topic (the first topic in the list of topics for that blog post).

0 Votes