CMS Development

pdaniel
Member

If a blog contains a topic display it at loop.index otherwise display latest

I cannot get this to work: I have allocated a blog with the topic in question - it is currently ignoring it - any help greatly appreciated.

 

There are 4 iterations - Snippet of the first  below:

 

////////////////////

{% set blog_one_posts = blog_recent_posts('3252017453', limit=100) %} {% set blog_two_posts = blog_recent_posts('4950691912', limit=100) %} {% set blog_three_posts = blog_recent_posts('4944930028', limit=100) %} {% set blog_four_posts = blog_recent_posts('4935075083', limit=100) %} {% set all_posts = (blog_one_posts + blog_two_posts + blog_three_posts + blog_four_posts) | sort(true, false, 'publish_date') %} {% for rec_post in all_posts %} {% if loop.index <= 4 %} <!-- 01 if the TOPIC latest-news-first exist - then do this: --> {% if loop.index == 1 %} {% if 'Latest-news-first' in rec_post.topic_list|map('slug') %} <script>console.log('thissss')</script> <div class="latestFeed"> <a href="{{ rec_post.absolute_url }}" class="latestTitle"> {% if rec_post.widgets.contentPost.body.value == "true" %} <img src="https://cdn2.hubspot.net/hubfs/606372/Assets_Whispir/Images/textPost.png" alt "text-post"> {% endif %} {% if rec_post.widgets.audioPost.body.value == "true" %} <img src="https://cdn2.hubspot.net/hubfs/606372/Assets_Whispir/Images/audioPost.png" alt "Audio-post"> {% endif %} {% if rec_post.widgets.videoPost.body.value == "true" %} <img src="https://cdn2.hubspot.net/hubfs/606372/Assets_Whispir/Images/videoPost.png" alt "video-post"> {% endif %} {{ rec_post.name }} </a> <a href="{{ rec_post.absolute_url }}" class="more-link">Read Full Story ></a> <label class="readTime">{{ rec_post.widgets.timeToRead.body.value }}</label> </div> {% else %} <div class="latestFeed"> <script>console.log('that')</script> <a href="{{ rec_post.absolute_url }}" class="latestTitle"> {% if rec_post.widgets.contentPost.body.value == "true" %} <img src="https://cdn2.hubspot.net/hubfs/606372/Assets_Whispir/Images/textPost.png" alt "text-post"> {% endif %} {% if rec_post.widgets.audioPost.body.value == "true" %} <img src="https://cdn2.hubspot.net/hubfs/606372/Assets_Whispir/Images/audioPost.png" alt "Audio-post"> {% endif %} {% if rec_post.widgets.videoPost.body.value == "true" %} <img src="https://cdn2.hubspot.net/hubfs/606372/Assets_Whispir/Images/videoPost.png" alt "video-post"> {% endif %} {{ rec_post.name }} </a> <a href="{{ rec_post.absolute_url }}" class="more-link">Read Full Story ></a> <label class="readTime">{{ rec_post.widgets.timeToRead.body.value }}</label> </div> {% endif %} {% endif %}

0 Upvotes
1 Reply 1
Jsum
Key Advisor

If a blog contains a topic display it at loop.index otherwise display latest

@pdaniel,

 

You should edit you question and share a formated version of your code. It's hard to understand what you are trying to accomplish in that wall of text.

0 Upvotes