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 %}
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