Questions tagged [theming]

Use it for questions about rendering or modifying the HTML markup produced by a module/theme.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

How to strip tags/ or just trim content but preserve ampersand in field content [duplicate]

The issue : striptags removes "&" from the fields content as well. {{ label }} preservers the "&" but I am not able to trim the content. I have twig_extender enabled <...
0
votes
0answers
11 views

Drupal 9 - Modules for background Video or Image

I'm yet another newbies excited about Drupal. For my sample site, I used the Adaptive Theme (no particular criteria for me selecting this theme). I just wanted to check is there a quicker way to add ...
0
votes
0answers
19 views

Twig: how to get values from [someName:protected]?

When I kint: {{ kint(elements.steps[0].step.description['#object']) }} I get: ... [activities:protected] => Array ( ( [17] => stdClass Object ( [...
0
votes
0answers
14 views
+50

Link to images in form view creates wrong url

I noticed this after drupal 9 update, but I've tried to find the exact moment when it was broken and I couldn't find it. I use S3 and cloudfront for images so maybe the problem is related with that ...
0
votes
0answers
10 views

Custom styled tables

I am trying to figure out a way for a content editor (with little to no coding experience) to add and style tables within their content. I was planning on creating a paragraph type where the editor ...
0
votes
1answer
26 views

Render two taxonomy fields in one alphabetical list

I have two term reference fields: colours and tags. I have a poppy, it has tags: pretty and colours: red, green. I want html like: This flower is: green, pretty, red i.e. I want to take the terms ...
2
votes
1answer
46 views

What is the difference/purpose of 'content' and 'elements' keys, in preprocess?

I'm using hook_preprocess_node and looking at $variables. I can see there's two similar keys: content and elements. I see that there's a comment in the core code: // Helpful $content variable for ...
0
votes
0answers
54 views

Twig templates with lots of classes?

I have created a twig template and have added classes like below. {% set title-classes = [ 'title', 'h1', ] %} {% set subtitle-classes = [ 'subtitle', 'h2', ] %} <div{{ ...
-3
votes
0answers
28 views

How to Display fivestar form in twig drupal 8 [closed]

How to Display fivestar form in list of node in twig drupal 8
0
votes
0answers
31 views

Is there Drupal Twig built-in ability to get content of page

Is there built in Drupal Twig ability (tag) to get content of another website's page like file_get_contents() or cURL do in PHP? Under "built in" I mean without adding a PHP code to a ...
0
votes
0answers
22 views

Image compression problem

I keep on running into an issue with image compression on Drupal. I have a set of good quality, clear images, that I'm resizing down to 100px by 100px in CSS. When I resize, the quality worsens and ...
0
votes
1answer
17 views

Get class on item.below (child item of menu) inside <li> tag in menu--main.html.twig

Hi I can't insert class in child item of main menu and remove existing. Part of my code looks like this: {% for item in items %} {% set item_classes = [ 'menu-item-edot', item....
0
votes
1answer
54 views

Middle part of a page disappears and appears again after flushing all caches

Sometimes middle part of some page at our website may disappear and only header and footer are still displayed. The problem is always solved after flushing all caches. Our html.html.twig loads ...
-2
votes
1answer
34 views

Pass multiple value in an session

How we can pass multiple value in an session variable $session = \Drupal::request()->getSession(); $session->set('session_anme', $variable_name ++); if I add value 1 and 2 and 3 The value ...
0
votes
1answer
35 views

How can I load a template from a custom module on a certain page?

I have a page at path /user/{id}/module, and I'm trying to have Drupal load a custom template from my module when this page is accessed. The twig debug output shows suggestions for the template name ...
0
votes
0answers
25 views

How to access data in Twig in module extended template

I'm new at developing Drupal. I'm using Drupal 8 and I want to display datetime fields in a special way. Here is how my module_name.module and template file looks like: function module_name_theme($...
0
votes
0answers
11 views

Front menu not showing subitems

I've generated my menu based on the menu template from the stable theme {% macro menu_links(items, attributes, menu_level) %} {% import _self as menus %} {% if items %} {% if menu_level == 0 %}...
0
votes
1answer
37 views

Twig\Error\LoaderError: Template "@theme/footer.html.twig" is not defined

I know there are similar questions to this that have been asked but none of the solutions are working for me and I've been at this all day so I thought I'd give this a try. I've created a sub-theme of ...
-2
votes
0answers
20 views

Date format for date type fields

I am using a date type fields in a custom form after click on the date pop up I want the date format in mm-dd-yyyy or yyyy-mm-dd but currently its showing dd-mm-yyyy. $form['start_date'] = [ '#type' ...
-1
votes
1answer
26 views

Add a date pop in a field in custom module

I want to add a date pop in a custom field in custom form in custom module This is the library file: custom_lib: css: theme: css/datebasesorting.css: {} css/datatables.min.css: {} ...
-1
votes
0answers
16 views

why am I seeing calls to themes.googleusercontent.com?

Drupal 9 - I'm using a custom subtheme of W3CSS theme and one of Adminimal for my admin theme. When I request a regular (non-admin) page, I'm seeing these errors in my console: downloadable font: kern:...
1
vote
3answers
32 views

How do I re-order a node's body and link fields in my Bartik subtheme?

I have a simple subtheme of the standard Bartik theme in Drupal 9.3.0. By default, when a node is rendered, its links, eg. "read more", "log in", come before the body. For example, ...
0
votes
0answers
15 views

How to display a field from a custom composite in a table's field then calculate?

I am trying to make a table to display an "item" custom composite's fields (qty, price) in a table and calculate them to show fillers. I attached a screenshot to give you a better clue. As ...
0
votes
3answers
37 views

How can I print a single field?

I've got a taxonomy page (https://www.dovericaricare.it/becharge) that I'm trying to customize using a twig template. I don't understand what syntax I should use to print fields like the logo ({{ ...
0
votes
1answer
24 views

Is it possible to render a region in a menu template?

In my Drupal 8 theme I have a template called __menu.html.twig which gets called in my page.html.twig I am trying to render a region within the __menu.html.twig where I can place blocks. I have ...
0
votes
2answers
35 views

How do I move a node's tags to be near its author information in my Bartik subtheme

I want to style a node's author data and tags slightly differently to the Bartik theme in Drupal 9.3. That is, rather than: Submitted by user1 on Mon, 1/1/70 Tags foo bar I'd like to have: ...
0
votes
1answer
33 views

How can I print view/edit/comment links? [closed]

I have a view that uses the "View content," "edit content," and "view comments" fields. I can't figure out how to print these in a custom twig template. I've tried: {{ ...
0
votes
1answer
21 views

Templating the user edit page

i'm using the theme startupgrowth lite and i want to theme my user edit page , only when the user is a 'testeur' and he's editing the 'candidate user profile'. i know that when i want to modify the ...
1
vote
1answer
53 views

how to convert date into timestamp using timezone

I am using strtotime to convert date into time stamp but its does not work correctly. I know its relatively to time zone. My drupal store time zone is denver. I am not sure why its not showing correct ...
0
votes
0answers
11 views

Display Default and filter data of a form on a same page including form

I want to show the date without filter a form that is default data and if user apply for filter and filter should be shown rather to default data including form at the top Basically I have created a ...
1
vote
1answer
59 views

Theming a EntityListBuilder.php table using drupal/examples/content_entity_example as base

Any idea how I could to use my own custom module twig file to theme my table? I'm using drupal/examples -> content_entity_example as a starting point: in content_entity_example.module implementing ...
0
votes
0answers
34 views

How can I conditionally display fields based on the same paragraph radio field value?

I have added a paragraph where I want to use a radio button to conditionally display text fields from that same paragraph. My radio values are: Select discount in amount -> if checked, then ...
0
votes
0answers
29 views

How to get the url of a link field in field.html.twig

Inside the field--link.html.twig file, I'm trying to output the url from a link field like so: {% for item in items %} <div{{ attributes.addClass(classes) }}><a class="button" ...
0
votes
0answers
19 views

Ho can I add a class to a specific row in views-view-field template?

I have created a custom views-view-field template and added some custom html and views field similar to this <div class="{{ fields.my_text_field.content }}"> {{ fields.my_media_field....
2
votes
0answers
19 views

How do I access current_page value in views twig template?

In views-view.html.twig, I'm trying pager['#views_plugin'].current_page, but don't get any value.
0
votes
1answer
78 views

hook_theme_suggestions_image_alter() not returning ['data-responsive-image-style']

Perhaps I have similar issue to this Drupal 9.2 template_preprocess_image hook not working. When I put this code in myTheme.theme function HOOK_theme_suggestions_image_alter(array &$suggestions, ...
0
votes
0answers
11 views

Print a node's image-field path on the template html.twig

I need to get this tag into the header so facebook can pick it up when I share links to the website. <meta id="page-image" property="og:image" content="node-image-field-...
4
votes
1answer
141 views

Loading individual css files for custom modules

I have a custom module that creates three pages. Each page has a controller, twig file, and css file. What I'd like to do is only load the css files when they are needed. I created a libraries.yml ...
0
votes
0answers
28 views

Strange behaviour of regions displays in D9 Bootstrap theme

I'm working on a site based on Drupal 9 and Bootstrap 5. I can normally create new regions and call them in the front.html.twig template, so that they are correctly displayed and rendered in the block-...
0
votes
0answers
14 views

Webform custom element layout twig

I am creating a custom webform element, im using the /modules/contrib/webform/webform_example_example, i installed the module and added the element to a form but now i want to customize the webform in ...
3
votes
1answer
127 views

What is the stable9 theme? When should I use it instead of stable?

https://www.drupal.org/node/3066038 Has this cryptic statement: However, defaulting to base theme: stable prevents automatic updates to the next major version of Drupal, since each major version may ...
1
vote
2answers
112 views

How to add class to multiple view-blocks using twig?

I have four blocks to a view. I want to add class 'fancy-body' to all four blocks. How can I add that. view_id : categories display_id's of blocks : block_1, block_2, block_3, block_4 I know, I can ...
1
vote
1answer
43 views

Altering custom template from code

How can I programmatically remove blocks and other elements from a single custom template ? In my custom modle I have defined a route to a controller which then loads a template which is also ...
1
vote
1answer
19 views

Adding a class to an image using preprocess function

I am having trouble adding a class to an image using a preprocessor function in Drupal 9. Specifically, I only want certain images to have that class added. The image is being added using paragraphs. ...
0
votes
1answer
16 views

Adding theme JS library in custom module

My theme documention.libraries.yml file is defined as follows : global-styling: version: VERSION css: base: styles/dist/styles.css: {} tocbot: js: libraries/tocbot/tocbot.js: {} ...
0
votes
2answers
26 views

Display a pager on the top and bottom of view pages but only on the bottom of view blocks

For a project running on Drupal 9.2.9, I want pagers on the top and bottom of view pages. I have it working on pages by an edit to a custom views-view.html.twig in the theme (using the full pager ...
0
votes
1answer
35 views

How to show a field in a view for another field?

I have twig template named views-view-field--banner--block_1--field-banner.html.twig Here I print <a href="">{{ output -}}</a> To put an anchor tag around an image field named ...
1
vote
1answer
59 views

Difference between a front-end theme and an administrative theme?

I am teaching myself Drupal 9 and I see that the Claro theme is defined as a "Drupal administration theme" while Olivero is defined as a "Drupal front-end theme." Are these ...
0
votes
1answer
23 views

Creating twig files for the a view

Hi there I'm new to Drupal. I have made a test project, where I've made a custom content-type called 'persons' it has a couple of values. And I made it able to custom style it by making a twig file ...
1
vote
3answers
60 views

Attempting to return region in theme suggestions for the book module book tree block

Editing question based on information from @NoSssweat The book module uses the same hook for the book tree block and the rendered index view in the book page. I have used the below code to return file ...

1
2 3 4 5
214