CMS Development

kaitlynwells
投稿者

Post Filter Customization

解決

Hello, i'm in need of some help to customize the Post Filter module. I was wondering if it was possible to only display certain tags for filtering. I have a few tags that I use specifically for feeding into an RSS feed, but I don't want those to show up in the Post Filter module. Thank you! 

0 いいね!
1件の承認済みベストアンサー
JasonRosa
解決策
HubSpot Employee
HubSpot Employee

Post Filter Customization

解決

Hey @kaitlynwells awesome thank you for posting your code and for the additional context. Could you try replacing the code in your module with this? I didn't realize you were filtering out a few different topics so I changed things around slightly. I think the endfor issue was because of an unclosed quote mark. 

 

{% set my_topics = blog_topics('default', 250) %}
<ul>
{% for item in my_topics %}
{% if item != "Marketplace" and item != "Contract Lifecycle Management Suite" and item != "Aquisition Suite" and item != "Program Management Suite" and item != "Financial Assistance Suite" %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
  {% endif %}
{% endfor %}
</ul>

 You can add the specific ID for your blog in place of "default" on line one in between the quotes. You can get your blog ID by going to your blog dashboard in the tool (Marketing > Website > Blog) and then choosing which blog you want to use from the top menu. The blog ID should be in the URL (would be the number that isn't your HubID). Example: 

 

https://app.hubspot.com/blog/[Hub ID]/blogs/[Blog ID]/manage/posts/all

元の投稿で解決策を見る

0 いいね!
7件の返信
JasonRosa
HubSpot Employee
HubSpot Employee

Post Filter Customization

解決

Hey @kaitlynwells the only way I think of to remove topics from the default Post Filter module would be to use JS to target and remove those links. Outside of that, my personal recommendation would be to create a custom module and use the blog topics function here (https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#blog-topics) and then add an if statement inside of that for loop in the function to exclude your selected topics. So something like this: 

 

{% set my_topics = blog_topics('Your Blog ID', 250) %}
  {% for item in my_topics %}
    {% if item != "your topic name %}
      <a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a>
    {% endif %}
  {% endfor %}
0 いいね!
kaitlynwells
投稿者

Post Filter Customization

解決

Hello two things: 1. How do I list multiple topics and 2. It's giving me back an error when i past that code in: 

Screen Shot 2019-03-21 at 9.07.27 AM.png
0 いいね!
JasonRosa
HubSpot Employee
HubSpot Employee

Post Filter Customization

解決

Hey @kaitlynwells so this should list out all topics on your blog outside of the one that you'd exclude on line 3 of the code snippet. If you're getting an error, would you mind sharing your code/linking to the module or template you're working on?

0 いいね!
kaitlynwells
投稿者

Post Filter Customization

解決

@JasonRosa  Forgive me I am not a developer and I definitely don't know Hubl 🙂 Below is the code. I cloned the default post filter. When playing with it, it doesn't seem to be closing out something so the endfor isn't registering. 

{% if module.select_blog is number %}
  {% set select_blog = module.select_blog %}
{% else %}
  {% set select_blog = 'default' %}
{% endif %}

{% set my_topics = blog_topics('default', 250) %}
<ul>
{% for item in my_topics %}
{% if item != "Marketplace, Contract Lifecycle Management Suite, Aquisition Suite, Program Management Suite, Financial Assistance Suite,  %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
  {% endif %}
{% endfor %}
</ul>

{% post_filter
  select_blog='{{ select_blog }}',
  expand_link_text='{{ module.expand_link_text }}',
  list_title='{{ module.list_title }}',
  filter_type='{{ module.filter_type }}',
  order_by='{{ module.order_by }}',
  max_links={{ module.max_links }}
%}
0 いいね!
JasonRosa
解決策
HubSpot Employee
HubSpot Employee

Post Filter Customization

解決

Hey @kaitlynwells awesome thank you for posting your code and for the additional context. Could you try replacing the code in your module with this? I didn't realize you were filtering out a few different topics so I changed things around slightly. I think the endfor issue was because of an unclosed quote mark. 

 

{% set my_topics = blog_topics('default', 250) %}
<ul>
{% for item in my_topics %}
{% if item != "Marketplace" and item != "Contract Lifecycle Management Suite" and item != "Aquisition Suite" and item != "Program Management Suite" and item != "Financial Assistance Suite" %}
<li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
  {% endif %}
{% endfor %}
</ul>

 You can add the specific ID for your blog in place of "default" on line one in between the quotes. You can get your blog ID by going to your blog dashboard in the tool (Marketing > Website > Blog) and then choosing which blog you want to use from the top menu. The blog ID should be in the URL (would be the number that isn't your HubID). Example: 

 

https://app.hubspot.com/blog/[Hub ID]/blogs/[Blog ID]/manage/posts/all

0 いいね!
kaitlynwells
投稿者

Post Filter Customization

解決

Thanks so much @JasonRosa  - Dumb question, I have  a domain name linked to my blog so I don't see and ID on the URL as you listed. Is there another way to find that number? The updated code still didn't filter the way I would like when I still have the default in. 

0 いいね!
JasonRosa
HubSpot Employee
HubSpot Employee

Post Filter Customization

解決

@kaitlynwells would you mind sending me a direct message with a link to the module you're working on? I'd be happy to take a closer look. It is a bit tough for me to tell what is fully going on in this case without it.