CMS Development

salman
Membro

Can we store custom variables such as {email.greetings} to can be used universally across templates?

resolver

I would like to use variables (large strings, etc) that I use across campaigns and workflows. I have learned here, that you can set variables using commands like:

{% set string_var = "This is a string value stored in a variable" %}
{{ string_var}}
 
However, the page does not explain where I store them. Ideally, I am expecting like a notes file where all the set variables have been stored, and can be called on any email or landing page.
 
I understand that these can be set in any given template itself, but i need to be able to call them  universally in any other template as well.
 
How can I achieve this? Thanks in advance.
1 Solução aceita
ndwilliams3
Solução
Conselheiro(a) de destaque

Can we store custom variables such as {email.greetings} to can be used universally across templates?

resolver

You could add an HTML module to a page or email template and make it a gobal module. Add your variables there. You would have to add the module to any template you want to use those variables.

 

Another option is the create a coded file to store those variables and call the file in your templates using the import function.

 

In the coded file, define your variables.

{% set string_var1 = "This is a string value 1 stored in a variable" %}

 

In the template, import your variables

{% import 'custom/page/hubl/variables.html' as variables %}

 

Use the variable in your template
{{variables.string_var1}}

Exibir solução no post original

2 Respostas 2
ndwilliams3
Solução
Conselheiro(a) de destaque

Can we store custom variables such as {email.greetings} to can be used universally across templates?

resolver

You could add an HTML module to a page or email template and make it a gobal module. Add your variables there. You would have to add the module to any template you want to use those variables.

 

Another option is the create a coded file to store those variables and call the file in your templates using the import function.

 

In the coded file, define your variables.

{% set string_var1 = "This is a string value 1 stored in a variable" %}

 

In the template, import your variables

{% import 'custom/page/hubl/variables.html' as variables %}

 

Use the variable in your template
{{variables.string_var1}}

aay
Participante

Can we store custom variables such as {email.greetings} to can be used universally across templates?

resolver

How did you code the separate file that is called upon?

0 Avaliação positiva