Hi there,
I’m building a template for a landing page and have create some custom modules.
On the editor, the creator can enable or not a module:
If the module is enable, it’ll be rendered in the landing page.
As you can see in the screen above, it’s checked by default, and the module is indeed rendered on the page when we just create it.
But if my Hubl template tries to get the
enable
value, null is received, not true:
{%
module "myModule"
path="../path/to/module",
label="My module"
%}
{{ content.widgets.myModule.body.enable }} // null
If the page creator toggles the
enable
switch, then the value is now updated correctly and the correct boolean is printed. Otherwise, null is received.
That’s said, I’ve understood that my template can override the default values set by the custom module, like below:
{%
module "myModule"
path="../path/to/module",
label="My module",
enable=true
%}
{{ content.widgets.myModule.body.enable }} // true!
When doing that, the default value is correctly gotten. Well, almost…
When creating a new page from the template, it seems that it works randomly. Sometimes it does and everything is OK, and sometimes it does not, and the creator has to reload the page to make it work. What do I do wrong?
Anyway, even when it works, it’s required to define this default value on the custom module and when calling it on the Hubl template, which is not so convenient…
So, this is the context, now my questions:
- Can you confirm that the correct way for a template to get actual module values is to set the default ones when calling it?
- If so, why does it work only sometimes?
- And what’s the point of defining default values directly on module fields (like my first screenshot) if we have to redefine them in the templates? It’s very confusing to not get them from the template.
Thanks in advance ![]()
