How to refer to a custom field in a node template?


The issue occurred because

{{ content.field_login_required }} 

was used. Node should be used in place of content. The proper code is

{{ node.field_login_required.value }}
Tags: Theming / Nodes / Drupal 8

Similar questions

Accidentally changed the path of an RSS feed page in Views to refer to a menu link item and cannot access Views menu anymore
I cannot access views from the Structure Menu in Drupal 8 anymore. I accidentally changed the path of an RSS feed page in Views to refer to a menu link item and cannot access the Views menu anymore. How does one fix this? I get an error that says "The website encountered an unexpected error. Please try again later when trying to access View Menu." ...
What's the proper way to refer to all the code in `core/lib/Drupal`, or the code in `core/lib/Drupal/Core' or `core/lib/Drupal/Core/Foo`?
When we say 'core' we mean the whole of Drupal core that you get from the Drupal project page. On D7, core code that wasn't in modules tended to be called 'the includes' IIRC. But on D8 they're not include files any more. They in core/lib/Drupal and we have: What's the correct way to refer to these?
What does 'engine' refer to in Drupal Theming?
I've been reading about Drupal theming and preprocess functions and noticed they listed engineName_engine_preprocess & engineName_engine_preprocess_hook in the order of preprocess functions but I'm not entirely sure what the engine layer is? I understand about the core, includes, modules and themes. Many thanks
In a composer file, what does "reference" refer to?
In my composer.lock file, I noticed that some packages have a reference value: And some just have null: What does the value refer to? I thought it refers to a commit, but both of these are zip packages, where 1 has a reference and the other does not.
How to use 2 twig template for for one field (or how to add a variable to a template from a template)
Let say I have a node template which is calling twice the same field like the following: I also have a preprocessing function which is adding VAR1 and VAR2 to the 'my_field' array like the following: I would like that the first call of 'My_field' use the default twig template and the 'VAR1' value... As you can imagine, I could do it as this is the ...
Custom page template for specific node - template inheritance
I'm trying to customize the page template for a specific node of a specific content type. This is what I have: Content type: Custom Page Node ID: 2 First, I need to customize all 'Custom Page' content nodes so I created a custom page template for them: page--custom-page.tpl.php Then, I also need to customize a specific 'Custom Page' node so I creat...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.