CMS Development

KShapovalov
Member

Variable in a custom module text field

SOLVE

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 Accepted solution
Anton
Solution
Thought Leader | Partner
Thought Leader | Partner

Variable in a custom module text field

SOLVE

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

View solution in original post

2 Replies 2
GRajput
Recognized Expert | Platinum Partner
Recognized Expert | Platinum Partner

Variable in a custom module text field

SOLVE

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


0 Upvotes
Anton
Solution
Thought Leader | Partner
Thought Leader | Partner

Variable in a custom module text field

SOLVE

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