Creating listing page by topic

I am trying to create a custom module that prints out a list of absolute links to individual blog posts. Each topic will have its own listing page. For example, there are fifty states in the USA. I create a listing page for each state and expect any blog post tagged will populate on their respective state listing pages. Also, if a post has multiple tags it should populate on all of the appropriate pages. In the analogy of the fifty states, if I write a blog post and tag it California and Ohio, the listing page for CA and OH will both have an absolute link to back to the post. I would like to sort each state listing page by date as well. Currently I am able to print all of the tags but not sort them into individual listing pages.

{% set posts = blog_tags(5664168304, 50) %}
{% for post in posts %}

{% if post.name == ‘California’ %}
<div class=“state-post-listing”>
<ul>
<li><a href=“{{post.absolute_url}}”>{{ post.name }}</a></li>
</ul>
</div>
{% endif %}

{% endfor %}

Hey @josephLayden if possible could you share a link to the page/preview page your are working on and links to th epages you want to feature?

@AJLaPorte_diagr what would you advise in this case?

https://community.hubspot.com/t5/Content-Design-Questions/Filter-HubDB-by-row-using-Hubl/m-p/184942#M5520

Hi @josephLayden,

Quick question, is there a reason you are doing this in a custom module and not using the normal topic listing pages? For example, your-blog-domain.com/topic/ohio

You can modify the blog listing template to show these types of content listings instead of using a custom module. It would look like this:

{% for content in contents %}
 {% if not simple_list_page %}
 {% if topic %}
 <a href="{{content.absolute_url}}">{{ content.name }}</a>
 {% else %}
 // Your normal look for blog listing here
 {% endif %}
 {% endif %}
{% endfor %}

This essentially is saying if it’s a topic listing page, show this content otherwise show the normal layout. You could make it more specific to the topic instead so it can be:

{% set stateList = ['ohio', 'california', 'illinois', .... ] %}
{% for content in contents %}
 {% if not simple_list_page %}
 {% if topic in stateList %}
 <a href="{{content.absolute_url}}">{{ content.name }}</a>
 {% else %}
 // Your normal look for blog listing and other topics not in stateList here
 {% endif %}
 {% endif %}
{% endfor %}

Hopefully this helps a bit and can be a different way to accomplish this without needing to maintain both your blog and a HubDB table

-AJ

For some reason the tagging is not working correctly for the built in plugin. For example, I tagged this post with the states (WI, IN, IL) > March 13, 2018 | Vigorous Job Market Expected for Chicago-Naperville-Joliet, IL-IN-WI MSA

However, the module renders incorrect tags instead.

There is having any option to show all the saved tags in blog page?

Not this !!! (bcaz i need to show all the saved tags not only the blog topics.)

<div class=“topic-list”>
<h3>Topics</h3>
{% set my_topics = blog_topics(‘default’, limit=250) %}
<ul>
{% for item in my_topics %}
<li><a href=“{{ group.absolute_url }}/topic/{{item.slug}}”>{{ item }}</a></li>
{% endfor %}
</ul>
</div>