La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
I would like to add custom fields to a blog post, for example a checkbox called "Featured Post". Then i would like to have access to this data within hubl code, so i can apply logic in the template
create an if-loop inside the blog-post template and wrap it around the featured post code. By doing so the author will get an option("module") when creating a new post.
create a new module with an if-loop and the featured post code. Personally I go almost always this way because it gives you much more flexibility(you could even show a featured post from another blog if you have mutliple ones). After creating this module you place the module where you want to show the optional featured post.
Here some code examples for both solutions
if-loop directly in template
{% boolean "show_featured_post" label='Show Featured post', value=True, export_to_template_context=True %}
...
{% if widget_data.show_featured_post %}
place your featured post code here
{% endif %}
place this code inside your blog-post(not listing) template. The if-loop should be in the place you would like to show the featured post.
if-loop in module and template
module
{% if module.show_featured_post %}
place your code here
{% endif %}
for the "easiest" use I would recommend to right-click the module in the left sidebar of the design-manager and select "Copy snippet". Place it in the template where you'd like to display the module. Also I recommend to add the no_wrapper=True option at the end of the module. This will minimize the sourcecode slightly by not using unneeded wrapping divs
create an if-loop inside the blog-post template and wrap it around the featured post code. By doing so the author will get an option("module") when creating a new post.
create a new module with an if-loop and the featured post code. Personally I go almost always this way because it gives you much more flexibility(you could even show a featured post from another blog if you have mutliple ones). After creating this module you place the module where you want to show the optional featured post.
Here some code examples for both solutions
if-loop directly in template
{% boolean "show_featured_post" label='Show Featured post', value=True, export_to_template_context=True %}
...
{% if widget_data.show_featured_post %}
place your featured post code here
{% endif %}
place this code inside your blog-post(not listing) template. The if-loop should be in the place you would like to show the featured post.
if-loop in module and template
module
{% if module.show_featured_post %}
place your code here
{% endif %}
for the "easiest" use I would recommend to right-click the module in the left sidebar of the design-manager and select "Copy snippet". Place it in the template where you'd like to display the module. Also I recommend to add the no_wrapper=True option at the end of the module. This will minimize the sourcecode slightly by not using unneeded wrapping divs
Hi @Demetri, Do you mean a checkbox for your team/customer who is creating the blog post per the visitors of the blog post who don't have access to hubspot?