Blog listing loop stops after topic exclusion

Highlighted
New Contributor

Hello fellow Hubspot developers,

 

I have this problem and you might be able to help me.

 

I'm working on a blog template. The idea is to make a listing in wich I exclude one category, here is the logic : 

<div class="blog-listing">
    <div class="wrapper">
	    {% for content in contents %}
		    {% for topic in content.topic_list %}
			  {% unless 'Web séries' in content.topic_list|map('name') %}
			  <div class="flex-item">
				  <h2>
				   {{ content.name }}
				  </h2>
				  <a class="topic-link {{ topic.slug }}" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>
			  </div>
			  {% endunless %}
			{% endfor %}
		{% endfor %}	
	</div>
</div>

I'm doing this with an 'unless', but it works also like this

<div class="blog-listing">
    <div class="wrapper">
	    {% for content in contents %}
		    {% for topic in content.topic_list %}
			  {% if topic.slug != "web-séries" %}
			  <div class="flex-item">
				  <h2>
				   {{ content.name }}
				  </h2>
				  <a class="topic-link {{ topic.slug }}" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>
			  </div>
			  {% endif %}
			{% endfor %}
		{% endfor %}	
	</div>
</div>

It works fine and it can also be done a number of other ways too. Each time I get only 3 posts in my listing instead of the 5 wich are specified in the settings of the blog template. (I have a number of 7 articles from wich 2 are from the exculsion topic)

 

It seems that the 'content in contents' with the condition removes the requested topic, but never goes on the next page in order to get the rest of articles in order to replace the one wich were excluded.

 

Any kind of help is apreciated,

 

Thank you

 

Reply
0 Upvotes
3 Replies 3
Community Manager

Hi @Theodor,

 

I want to tag in a few users who may have some tips on this.

 

@Stephanie-OG@dennis_e@himanshurauthan do you have any tips for @Theodor?

 

Thank you,
Jenny


Did my post help answer your query? Help the Community by marking it as a solution
Reply
0 Upvotes
Regular Advisor | Platinum Partner

@Theodor try

% if topic.slug is not string_containing "web-séries" %}
dennis
New Contributor

Hi Dennis,

 

Thank you for your reply. Sorry for the late reply.

 

I found a work around to my problem. I'm searching the missing articles on page number 2 and loading them on the first page in AJAX.
It's pretty complicated dew to the fact that the same loop which generates the listing of articles is the loop which generates the categories listing, author listing and search results listing.

I took me 2 more days but got it to finally work.

 

Thank you again,

 

Theodor,

Reply
0 Upvotes