Variable in a custom module text field

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

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:

best,

Anton

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!