CMS Development

Nikki_ROBIN
Contributor

Custom Module not appearing in certain templates

SOLVE

Hello everyone, 

 

I've made a custom module for my blog pages, which shows the most recent page containing a certain topic. I have two templates in which this custom module is shown, the blog post template and the blog template itself. 

 

The custom module looks great in the blog post template, but it doesn't appear in the blog template. I don't know if this is enough info, but below you can see the template with the custom module (postlisting (kort nieuws)). 

 

Template Blog Post (working)Template Blog Post (working)Template Blog (not working)Template Blog (not working)

 

Any help is appreciated! 

0 Upvotes
2 Accepted solutions
TRooInbound
Solution
Key Advisor | Partner
Key Advisor | Partner

Custom Module not appearing in certain templates

SOLVE

Hi @Nikki_ROBIN,

 

Yes, We are just trying that out. On blog posting, there is no meaning of the related post. It is relevant to blog posting page only.

 

We think you are looking for the filtering post items in post listing page, you need to add your topic name as a second option in blog_recent_topic_posts method as per below code

 

{% set topic_posts = blog_recent_topic_posts('default', 'your-topic', 5) %}
{% for topic_post in topic_posts %}
    <div class="post-title">{{ topic_post.name }}</div>
{% endfor %}

Note: It accepts a lowercase hyphenated name. For eg. topic name is lead generation then need to add parameter as 'lead generation'.

 

We hope it works for you.

Team TRooInbound!

 

View solution in original post

0 Upvotes
Nikki_ROBIN
Solution
Contributor

Custom Module not appearing in certain templates

SOLVE

Thank you for helping me! 

 

I actually fixed it with a different solution. I created a specific tag (kort nieuws) RSS feed and that solved it. 

View solution in original post

7 Replies 7
Nikki_ROBIN
Contributor

Custom Module not appearing in certain templates

SOLVE

To be honest, I think it's just not possible this way. 

I created this custom module with this guide: http://designers.hubspot.com/tutorials/creating-a-related-post-section-with-hubl 

 

And in this guide it specifically says 'related blog posts for inside you blog post template'. 

 

I think that's why it doesn't work on my blog template. 

 

If anyone's knows a way to create a blog listing module, filtered to show only blogs with a certain topic, I'd love to hear it. 

TRooInbound
Solution
Key Advisor | Partner
Key Advisor | Partner

Custom Module not appearing in certain templates

SOLVE

Hi @Nikki_ROBIN,

 

Yes, We are just trying that out. On blog posting, there is no meaning of the related post. It is relevant to blog posting page only.

 

We think you are looking for the filtering post items in post listing page, you need to add your topic name as a second option in blog_recent_topic_posts method as per below code

 

{% set topic_posts = blog_recent_topic_posts('default', 'your-topic', 5) %}
{% for topic_post in topic_posts %}
    <div class="post-title">{{ topic_post.name }}</div>
{% endfor %}

Note: It accepts a lowercase hyphenated name. For eg. topic name is lead generation then need to add parameter as 'lead generation'.

 

We hope it works for you.

Team TRooInbound!

 

0 Upvotes
Nikki_ROBIN
Solution
Contributor

Custom Module not appearing in certain templates

SOLVE

Thank you for helping me! 

 

I actually fixed it with a different solution. I created a specific tag (kort nieuws) RSS feed and that solved it. 

TRooInbound
Key Advisor | Partner
Key Advisor | Partner

Custom Module not appearing in certain templates

SOLVE

Hi @Nikki_ROBIN,

 

As blog structure contains HubL code which is not displayed right now, so we can't figure out the issue, can you provide limited access/scrren share, so we can look into it and resolve issue as soon as possible. or you can mail us on hello@trooinbound.com.

 

Team TRooInbound!

0 Upvotes
Nikki_ROBIN
Contributor

Custom Module not appearing in certain templates

SOLVE

Hi there, thanks so much for your reply. 

 

This is the code inside the custom module. Does that help? 

 

{% if content.topic_list %}
<h3>Kort nieuws</h3>
{% for topic in content.topic_list %}
{% if loop.first %}
{% set related_posts = blog_recent_topic_posts('Kort nieuws', topic.slug, 5 ) %}
{% for post in related_posts %}
{% unless content.absolute_url == post.absolute_url %}
<ul class="related-post-item">
<li class="related-title"><a href="{{post.absolute_url}}">{{ post.name}}</a></li>
</ul>
{% endunless %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

 

 

TRooInbound
Key Advisor | Partner
Key Advisor | Partner

Custom Module not appearing in certain templates

SOLVE

Hi @Nikki_ROBIN,

 

We think the issue is due to the filter you applied, Instead of 'Kort nieuws' you may need to replace with the blog ID of that blog.

 

You can select your blog from:

Content > Blog > Select your particular blog from dropdown

 

Below is attached screenshot where blog ID is highlighted from where you got your blog id.

 

Capture.PNG

 

We hope it works for you.

 

Team TRooInbound.

0 Upvotes
Nikki_ROBIN
Contributor

Custom Module not appearing in certain templates

SOLVE

Hello!

 

Thank you for the suggestion.

 

I've tried it, but it unfortunately doesn't work. The filter 'kort nieuws' is by the way rather important, because those are the only blogs that are supposed to be listed. 

0 Upvotes