CMS Development

megawattmedia
Contributor

show all blog posts link

SOLVE

what is the most effecient way to create a "show all" listings blog link? 

 

ive done this to show all of particular topic but how would i just show everything ?

 

what would the URL be? 

 

with topics its.... 

 

<li><a href="{{ group.absolute_url }}/topic/cakes">CAKES</a></li>

0 Upvotes
5 Accepted solutions
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

This is built into the Hubspot cos. In your blog markup you will see:

 

Checkout this pagination code I pulled from the HubL docs for blog markup:

{% if not simple_list_page %}
                <div class="blog-pagination">
                    {% if last_page_num %}
                        <a class="previous-posts-link" href="{{ blog_page_link(last_page_num) }}">Previous</a>
                    {% endif %}
                        <a class="all-posts-link" href="{{ group.absolute_url }}/all">All posts</a>
                    {% if next_page_num %}
                        <a class="next-posts-link" href="{{ blog_page_link(next_page_num) }}">Next</a>
                    {% endif %}
                </div>
                {% endif %}

basically all posts can be found at "website.com/blog/all" so do what you did in your example just replace /topics/cakes with /all and you are good to go.

View solution in original post

Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

Kind of only not like that. check out the HTTP Request Variables section here.

{% if request.domain == {{ group.absolute_url }}/all %}

{% endif %}

I haven't done this exact thing before but something like this should work. What you have doesn't work because group.absolute_url equals the absolute url of the blog (no sub pages or queries) so it cannot equal /all therefore it would always be false.

 

request.domain grabs the actual url out of the address bar, whatever it is, you can then check it against your condition. 

View solution in original post

Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

Well there isn't a variable for /all so as far I can tell there isn't a way to signify that you are on an all posts page unless you condition the domain. If you find something else please share.

View solution in original post

Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

ah yes you could use:

{% if is_listing_view %}

{% else %}

{% endif %}

but it would set all simple pages (all post, posts by topic, archive). You could do:

{% if is_listing_view %}
    {% if topic %}
         posts about {{ topic }} (heading if filtered by topic)
    {% else %}
         All posts (heading if all posts)
    {% endif %}
{% else %}
     Normal Heading
{% endif %}

The only issue is that filtering by date would be a wild card here as it would show the All Posts header. I have been meaning to look for a way to check if filtered by date but I haven't gotten to it yet so I don't know if it is possible. The {% if topic %} statement is checking if the variable topic is empty. The {{ topic }} variable is empty unless filtering by a topic, then it contains that topic. 

 

View solution in original post

0 Upvotes
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

If you want to use the same layout as your normal listing page and use pagination and you can just remove the {%if not simple_list_page %} condition from your {% for content in contents %} loop. 

View solution in original post

0 Upvotes
12 Replies 12
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

This is built into the Hubspot cos. In your blog markup you will see:

 

Checkout this pagination code I pulled from the HubL docs for blog markup:

{% if not simple_list_page %}
                <div class="blog-pagination">
                    {% if last_page_num %}
                        <a class="previous-posts-link" href="{{ blog_page_link(last_page_num) }}">Previous</a>
                    {% endif %}
                        <a class="all-posts-link" href="{{ group.absolute_url }}/all">All posts</a>
                    {% if next_page_num %}
                        <a class="next-posts-link" href="{{ blog_page_link(next_page_num) }}">Next</a>
                    {% endif %}
                </div>
                {% endif %}

basically all posts can be found at "website.com/blog/all" so do what you did in your example just replace /topics/cakes with /all and you are good to go.

megawattmedia
Contributor

show all blog posts link

SOLVE

perfect that's exactly what i was looking for! thanks! 

 

I also had a query about re-styling the blog social sharing module - the one that is output using this hubl really does fit with the website styling the icons just look bag, can't seem to find an easy way of just using nice neat matching icons...

 

{% blog_social_sharing "blog_social_sharing" overrideable=False, label='Blog Social Sharing' %}

0 Upvotes
Jsum
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

{% widget_block social_sharing "my_social_sharing" label='Social Sharing', use_page_url=True, overrideable=True  %}
        {% widget_attribute "pinterest" is_json=True %}{"custom_link_format": "", "pinterest_media": "http://cdn1.hubspot.com/hub/158015/305390_10100548508246879_837195_59275782_6882128_n.jpg", "enabled": true, "network": "pinterest", "img_src": "https://static.hubspot.com/final/img/common/icons/social/pinterest-24x24.png"}{% end_widget_attribute %}
        {% widget_attribute "twitter" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "twitter", "img_src": "https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png"}{% end_widget_attribute %}
        {% widget_attribute "google_plus" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "google_plus", "img_src": "https://static.hubspot.com/final/img/common/icons/social/googleplus-24x24.png"}{% end_widget_attribute %}
        {% widget_attribute "linkedin" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "linkedin", "img_src": "https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png"}{% end_widget_attribute %}
        {% widget_attribute "facebook" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "facebook", "img_src": "https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png"}{% end_widget_attribute %}
        {% widget_attribute "email" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "email", "img_src": "https://static.hubspot.com/final/img/common/icons/social/email-24x24.png"}{% end_widget_attribute %}
{% end_widget_block %}

This is in the Hubl docs under the social share module. You can just replace the image links.

 

The only issue I have found with this is that the images seam to be processed at a very small size and increasing the size with css only makes them blurry. I haven't played with it much though so it might be an easy fix. 

megawattmedia
Contributor

show all blog posts link

SOLVE

thanks for that! 

 

just back to the show all posts.. still trying to make this work..would an if statement that compares the url be ok to display my show all posts?

 

{% if is_listing_view %}
{% if {{group.absolute_url}}=={{group.absolute_url}}/all %}
<h1>THESE ARE ALL MY POSTS</h1>
{% elif topic %}

0 Upvotes
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

Kind of only not like that. check out the HTTP Request Variables section here.

{% if request.domain == {{ group.absolute_url }}/all %}

{% endif %}

I haven't done this exact thing before but something like this should work. What you have doesn't work because group.absolute_url equals the absolute url of the blog (no sub pages or queries) so it cannot equal /all therefore it would always be false.

 

request.domain grabs the actual url out of the address bar, whatever it is, you can then check it against your condition. 

megawattmedia
Contributor

show all blog posts link

SOLVE

great thanks! but also in theory shoud i not have to use this type of method the "show all" option is to some extent built in? 

0 Upvotes
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

Well there isn't a variable for /all so as far I can tell there isn't a way to signify that you are on an all posts page unless you condition the domain. If you find something else please share.

megawattmedia
Contributor

show all blog posts link

SOLVE

i think you're right, im thinking of "simple list" that CAN output all.. this seems to be the solution for this one!

0 Upvotes
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

ah yes you could use:

{% if is_listing_view %}

{% else %}

{% endif %}

but it would set all simple pages (all post, posts by topic, archive). You could do:

{% if is_listing_view %}
    {% if topic %}
         posts about {{ topic }} (heading if filtered by topic)
    {% else %}
         All posts (heading if all posts)
    {% endif %}
{% else %}
     Normal Heading
{% endif %}

The only issue is that filtering by date would be a wild card here as it would show the All Posts header. I have been meaning to look for a way to check if filtered by date but I haven't gotten to it yet so I don't know if it is possible. The {% if topic %} statement is checking if the variable topic is empty. The {{ topic }} variable is empty unless filtering by a topic, then it contains that topic. 

 

0 Upvotes
megawattmedia
Contributor

show all blog posts link

SOLVE

thanks i've kind of already got that setup, so i'm currently either outputting either a selective top listing page or a  blog home page where ive got the lastest or most items, but i need a third listing page which would be my all posts page, im thinking to just add the pagination using javascript as i can then style how i like.

 

  {% if is_listing_view %}
    
{% if topic %} posts about {{ topic }} (heading if filtered by topic) {% else %}

{% if request.domain == {{ group.absolute_url }}/all %}
all posts
{% endif %}
{% else %}
All posts (heading if all posts)
{% endif %}
{% else %}
Normal Heading
{% endif %}

 





 
 
0 Upvotes
megawattmedia
Contributor

show all blog posts link

SOLVE

mm that's not working...

 

{% if is_listing_view %} <!-- master if -->

{% if topic %}
this is topic view
{% elif request.absolute_url == {{ group.absolute_url }}/all %}
this is all view

{% else %}
this is home view
{% endif %}

 


{% else %} <!-- master else -->

this is a blog post

{% endif %} <!--master endif -->

0 Upvotes
Jsum
Solution
Key Advisor

show all blog posts link

SOLVE

@megawattmedia,

 

If you want to use the same layout as your normal listing page and use pagination and you can just remove the {%if not simple_list_page %} condition from your {% for content in contents %} loop. 

0 Upvotes