CMS Development

ballonura
Participante

Error:"module" is disabled in this context

resolver

I try to use global module inside another module like this:

{% module path="/Global content/Global Groups/Oceania Theme 2016/Oceania Theme 2016/Blog Email Subscription" %}

And always get the following errors: 

 

Error:"module" is disabled in this context

And

Error: Cannot resolve property "module"
 

I've searched a lot, but no luck. 

Thanks in advance for your help. 

0 Avaliação positiva
1 Solução aceita
piersg
Solução
Conselheiro(a) de destaque

Error:"module" is disabled in this context

resolver

No, you'll have to create a new HTML + HubL file, then copy-paste your code and edit the HubL variables e.g. replace something like {{module.title}} with {{title}} and make sure all variables are passed as arguments to the macro

{% macro myMacro(title, btn_text, btn_url) -%}
<div class="foo">
  <h1>{{title}}</h1>
  <a href="{{btn_url}}">{{btn_text}}</a>
</div>
{%- endmacro %}

 

Then use the macro in a module like so with the module variables in the relevant positions in the arguments list.

{% from '[macro url]' import myMacro %}
{{ myMacro(module.title, module.btn_text, module.btn_url) }}

 

Exibir solução no post original

3 Respostas 3
piersg
Solução
Conselheiro(a) de destaque

Error:"module" is disabled in this context

resolver

No, you'll have to create a new HTML + HubL file, then copy-paste your code and edit the HubL variables e.g. replace something like {{module.title}} with {{title}} and make sure all variables are passed as arguments to the macro

{% macro myMacro(title, btn_text, btn_url) -%}
<div class="foo">
  <h1>{{title}}</h1>
  <a href="{{btn_url}}">{{btn_text}}</a>
</div>
{%- endmacro %}

 

Then use the macro in a module like so with the module variables in the relevant positions in the arguments list.

{% from '[macro url]' import myMacro %}
{{ myMacro(module.title, module.btn_text, module.btn_url) }}

 

ballonura
Participante

Error:"module" is disabled in this context

resolver

there is way to convert from global module to macros?

0 Avaliação positiva
piersg
Conselheiro(a) de destaque

Error:"module" is disabled in this context

resolver

Hi @ballonura, you can't have modules within modules in HubL. If you want to include some sort of repeatable code in a module you could use macros instead.