CMS Development

Theodor
参加者 | Elite Partner
参加者 | Elite Partner

Blog listing loop stops after topic exclusion

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

 

0 いいね!
3件の返信
dennisedson
HubSpot製品開発チーム
HubSpot製品開発チーム

Blog listing loop stops after topic exclusion

@Theodor try

% if topic.slug is not string_containing "web-séries" %}
Theodor
参加者 | Elite Partner
参加者 | Elite Partner

Blog listing loop stops after topic exclusion

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,

0 いいね!
jennysowyrda
コミュニティーマネージャー
コミュニティーマネージャー

Blog listing loop stops after topic exclusion

Hi @Theodor,

 

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

 

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

 

Thank you,
Jenny

0 いいね!