CMS Development

Craig
Top Contributor

Blog post selector field - v2 custom modules

It appears that the 'Page' option under 'Selectors' column in v2 custm module field types presents the user with a list of landing pages to select, yet the 'Blog' selector only allows the user to select an entire blog - not an individual post.

 

Am I missing something?

 

6 Replies 6
PDeT
Participant

Blog post selector field - v2 custom modules

for anyone landing here through googling how to add a blog selector: the Page selector field also searches blogs and allows you to add blogs. Now ideally I would love this field to be limited to only search blogs so that you don't end up fetching pages with the blog_by_id function...

0 Upvotes
bmccluskey
Participant | Partner
Participant | Partner

Blog post selector field - v2 custom modules

Absolutely baffled that this is still an issue. If you have a selector for all website pages and a selector for a blog as a whole, why isn't there a selector for a specific blog post? Definitely needs to go into the pipeline. 

Jsum
Key Advisor

Blog post selector field - v2 custom modules

@Craig,

 

That appears to be the case. Blog article pages are available in navigation settings. 

 

You could set the value of "blog_post_by_id" to a text field in your custom module:

{% set my_post = blog_post_by_id(module.blog_id.textfield) %}

Then use the result in your markup, like in the docs example:

<ul>
    <li>
        <a href="{{ my_post.absolute_url }}">{{my_post.title}}</a>
    </li>
</ul>

You just have to find the blog post id. I would like to know if there is a better way to find this, but if you go to the details page for any page or blog post then look at the url, the second number is the blog post id:

https://app.hubspot.com/content-detail/xxxxxxx/blog-post/5688172099/performance

 

Need help? Hire Us Here

0 Upvotes
Craig
Top Contributor

Blog post selector field - v2 custom modules

@Jsum

Thanks - but would actually be easier to get them to paste a link rather than getting the user to find an ID. I was hoping to avoid that though - since the blog posts will be HubSpot content it makes sense that the dropdown behave the same way for the user that the Page selector does.

 

Anything in the pipleine do you think?

0 Upvotes
Jsum
Key Advisor

Blog post selector field - v2 custom modules

I wouldn't know who to ask about that. 

 

If you could dynamically create choice fields then you could loop through the blog posts to create a drop down out of the titles. I used the choice field from the docs and it doesn't give errors, but it also doesn't include the choice field in the module preview so if it does apply it to the page it would be outside the module. Just like the page selector field, the original choice module isn't the same as the custom module's choice field.

 

Other than that I would say you are left with the text field or blog post id.

 

Need help? Hire Us Here

0 Upvotes
Craig
Top Contributor

Blog post selector field - v2 custom modules

@Jsum good idea - but I tried that in a different project and yeah, it doesn't let you dynamically create the choice field within a v2 custom module.

 

Thanks anyway!

0 Upvotes