CMS Development

mike_mitchell
Participant | Platinum Partner
Participant | Platinum Partner

HubL - if all but last blog listing page?

I have a section of code that inserts specific global groups between posts on the blog listing page at specific intervals.  Due to there not always being enough posts on the last page, this sometimes causes issues.  For this reason, I am trying to write a statement that says execute this code if it is not the last listing page.  Below I have what I came up with in red, but it does not seem to be working.  Any suggestions on how I can change this if statement to make it work? 

 

{% if current_page_num != last_page_num %}
    {% if loop.index == 1 %} 
    <div class="popular-posts">
        {% include "/generated_global_groups/12345671030.html" %}
    </div>
    {% endif %}
    {% if loop.index == 4 %} 
    <div class="sub-to-blog-tile">
        {% include "/generated_global_groups/12345677193.html" %}
    </div>
    {% endif %}
    {% if loop.index == 9 %} 
    <div class="sub-to-blog-tile">
        {% include "/generated_global_groups12345676879.html" %}
    </div>
    {% endif %} 
{% endif %}
0 Upvotes
4 Replies 4
SandyG1
Contributor | Partner
Contributor | Partner

HubL - if all but last blog listing page?

Hi @mike_mitchell 

 

I've not yet ventured into this code but having a quick gander.

Could the statement be

 

contents.total_page_count

{% if current_page_num != contents.total_page_count %}

 

psdtohubspot
Key Advisor

HubL - if all but last blog listing page?

Hi @mike_mitchell 

 

Please Try this condition 

 

{% set total_pages = contents.total_page_count %} <!-- sets variable for total pages -->
{% if current_page_num != total_pages %} 

{% if loop.index == 1 %}
<div class="popular-posts">
{% include "/generated_global_groups/12345671030.html" %}
</div>
{% endif %}
{% if loop.index == 4 %}
<div class="sub-to-blog-tile">
{% include "/generated_global_groups/12345677193.html" %}
</div>
{% endif %}
{% if loop.index == 9 %}
<div class="sub-to-blog-tile">
{% include "/generated_global_groups12345676879.html" %}
</div>
{% endif %}




{% endif %}

Hope this works, let me know if any questions.

 

Thanks

Ajit

 

mike_mitchell
Participant | Platinum Partner
Participant | Platinum Partner

HubL - if all but last blog listing page?

That seems to have done the trick!  I appreciate your help!

psdtohubspot
Key Advisor

HubL - if all but last blog listing page?

Thanks  @mike_mitchell 

0 Upvotes