Preprocess a twig template file
Preprocess hooks are named MY_MODULE_preprocess_TEMPLATE_NAME, in your case:

function my_module_preprocess_node__myfile(&amp;$variables) {}


Notice how I replace the template's dashes with underscores in the function name.

Now you can get the display variable from $variables['node']-&gt;field_display-&gt;value.