Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

3

In your "task" module you must have a task_theme function where you've defined your templates. In there you'll need to update with your new paths too. e.g. This 'template' => "field--expire-date.html.twig" becomes: 'template' => "fields/field--expire-date.html.twig"


3

Use the Twig path() function and build a node route with the target id of the reference field: paragraph.html.twig {% if paragraph.field_example.target_id %} <a href="{{ path('entity.node.canonical', {'node': paragraph.field_example.target_id}) }}">{{ 'View node page'|t }}</a> {% endif %} See https://www.drupal.org/docs/8/theming/twig/...


2

I'd suggest to use core's Custom content blocks to create blocks (similar to your banner paragraph for nodes). Then you've got two options: You can either use Block Layout to place the blocks, but limit visibility of the block to certain pages/URLs. Pro: You can directly place the block in any region. Con: It will clutter up your Block layout page if you've ...


2

The least hassle way is to install Drupal Console Then run the command drupal site:mode dev (turns off caching and turns on twig debug) Once you're done, run drupal site:mode prod (turns off twig debug, turns caching back on).


2

If you want to only override the field template. Try with with the following. Implement hook_theme like the following no needs for variables and file keys. /** * Implements hook_theme(). */ function myModule_theme($existing, $type, $theme, $path) { return [ 'field__parent_task' => [ 'template' => 'field--parent-...


2

I had a project that needed some specific markup for different fields, using field.html.twig only at least saved managing multiple files. field.html.twig: {% set themeGroupOne = [ 'first_field', 'second_field', ] %} {% set themeGroupTwo = [ 'third_field', 'fourth_field', ] %} {# field markup option #} {% if field_name in ...


1

You can try this instead {% if element['#items'][key].value == 'active' %}


1

If the content that you refer to is a node then you can use the twig path function as follows: <a href="{{ path('entity.node.canonical', {'node': content.id}) }}">{{ 'Example text'|t }}</a>


1

You can do the following in your .theme file: function MYTHEME_preprocess_node(&$variables) { $variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage(); } And then in your node--page--full.html.twig (name of twig file depending on content type and view mode) use: {% if is_front %} // frontpage stuff here {% else %} // other stuff ...


Only top voted, non community-wiki answers of a minimum length are eligible