CMS Development

KShapovalov
Miembro

Variable in a custom module text field

resolver

Hello, can I use variables defined in a custom module inside a text field of that module in the content manager?

KShapovalov_0-1731477989722.png

 

1 Soluciones aceptada
Anton
Solución
Líder intelectual | Partner
Líder intelectual | Partner

Variable in a custom module text field

resolver

Hi @KShapovalov

yes it's possible.

In order to use variables, you have to define them somewhere. It can be the module itself or an external file(recommended if you want to reuse variables in different places).

 

Here's an example:

{% set my_variable = "Hello World" %} {# Module specific variable #}
{% import 'PATH-TO-VARIABLES-FILE.html' %} {# Importing a file from outside the module #}

{{ module.text_field }}

 

Result:

Bildschirmfoto 2024-11-13 um 15.57.36.png

 

best, 

Anton

Anton Bujanowski Signature

Ver la solución en mensaje original publicado

2 Respuestas 2
GRajput
Experto reconocido | Partner nivel Platinum
Experto reconocido | Partner nivel Platinum

Variable in a custom module text field

resolver

Hi @KShapovalov 

 

Yes, You can use the variable in the text field if you have defined this variable in your module like this

{% set var1 = '123' %}

 

 

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

 




Gaurav Rajput
Director, MarTech( Growth Natives)

Book a meeting


Anton
Solución
Líder intelectual | Partner
Líder intelectual | Partner

Variable in a custom module text field

resolver

Hi @KShapovalov

yes it's possible.

In order to use variables, you have to define them somewhere. It can be the module itself or an external file(recommended if you want to reuse variables in different places).

 

Here's an example:

{% set my_variable = "Hello World" %} {# Module specific variable #}
{% import 'PATH-TO-VARIABLES-FILE.html' %} {# Importing a file from outside the module #}

{{ module.text_field }}

 

Result:

Bildschirmfoto 2024-11-13 um 15.57.36.png

 

best, 

Anton

Anton Bujanowski Signature