CMS Development

AShrivastava4
Member

Couldn't locate Hubl variable in blog post URL.

SOLVE

Hi, We have created dynamic footer based on the URL slug of website page. However, couldn't locate HubL variable for the blog post URL in the knowledge base. below code written to dynamically switch between footer. Could someone please confirm if this code will be able to handle blog listing and pages to dynamically switch footer? If not, is there any HubL variable that needs to be included?

 

<style>
{# {% if widget_data.module_16425138492573.current_page == '1' %} #}
{% set current_url = request|urlize %}
{% if current_url is string_containing "/carriers" %}
.drivers_footer{
display:none;
}
{% else %}
.carriers_footer{
display:none;
}
{% endif %} #}
</style>

0 Upvotes
1 Accepted solution
Brownstephen101
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Couldn't locate Hubl variable in blog post URL.

SOLVE

If I'm understanding the question correctly, you just need to check if a specific string is in the url, if that's the case, the following would work:

{% if 'blog' in content.absolute_url #}
{# Blog HTML #}
{% else %}
{# Non-blog HTML #}
{% endif %}


Note: If you are doing css, ensure that you are not in a modules css section, because you can't access hubl from there.

Hope that help.

View solution in original post

1 Reply 1
Brownstephen101
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Couldn't locate Hubl variable in blog post URL.

SOLVE

If I'm understanding the question correctly, you just need to check if a specific string is in the url, if that's the case, the following would work:

{% if 'blog' in content.absolute_url #}
{# Blog HTML #}
{% else %}
{# Non-blog HTML #}
{% endif %}


Note: If you are doing css, ensure that you are not in a modules css section, because you can't access hubl from there.

Hope that help.