Blog post is not rendering DisabledException: 'module' is disabled in this context

{% set SAFE_BLOG = 232829990938 %}
{% set SAFE_LIMIT = module.number_of_posts %}
{% set SAFE_TAG = module.blog_filer_options.tag_field.slug %}
{% set POST_TYPE = module.blog_filer_options.select_post_type %}

{% set posts = [] %}

{% if POST_TYPE == ‘blog_recent_posts’ %}
{% set posts = blog_recent_posts(SAFE_BLOG, SAFE_LIMIT) %}
{% elif POST_TYPE == “blog_popular_posts” %}
{% set posts = blog_popular_posts(SAFE_BLOG, SAFE_LIMIT, ‘’) %}
{% elif POST_TYPE == “filter_by_tags” %}
{% set posts = blog_recent_tag_posts(SAFE_BLOG, SAFE_TAG, SAFE_LIMIT) %}
{% endif %}
in my module whenever i use hardcoded blog id like
{% set SAFE_BLOG = 232829990938 %} this my code works perfect
but there is a dropdown field in my module where to select the blog.
so I used this
{% set SAFE_BLOG = module.blog_filer_options.select_blog %}
and getting this error ( DisabledException: ‘module’ is disabled in this context )

can anyone tell me.
{% set SAFE_BLOG = 232829990938 %} why this working
{% set SAFE_BLOG = module.blog_filer_options.select_blog %} why not this one. even both are numaric data.

Hi @Shatak1, I hope that you are well!
Thanks for reaching out to the HubSpot Community!
Here are some resources that might help you:
- export_to_template_context
- Module and theme fields
Now, let’s consult our Top Experts: Hi @sylvain_tirreau, @Anton and @tmcginnis do you have suggestions to help @Shatak1, please?
Thanks so much and have a wonderful day!
Bérangère

Hi @Shatak1 ,

If the HubL code you shared is used inside a module template, module.blog_filter_options.select_blog works as expected.

But if that same code is placed in another template file, it won’t work directly.

In that case, you need to add the module to your template (either by drag-and-drop or by hard-coding it), and then use:

widget_data.your_module_id.blog_filter_options.select_blog

instead of:

module.blog_filter_options.select_blog

As far as I know, this should also work when the module is added by drag-and-drop.

Best,