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
1answer
53 views

I'm unable to access variables in template from preprocess function

I am using a preprocess function to get data from specific content types. I am able to print the data in the pre-process function but unable to view the same in the twig file. This is the code I am ...
0
votes
0answers
68 views

Why does “Barrio” subtheme already include some templates?

I'm creating a subtheme for Barrio, based on the subtheme included in the Barrio theme folder. It has already a template folder with some templates in it but, in my experience with other base themes, ...
1
vote
1answer
56 views

How can I pass multiple values to drupal_view()?

I'm on Drupal 8 and I have a view with multiple argument (list of node ID) but I can't embed this on my node.twig.html. That's my code: {% set myArray = [] %} {% for item in content....
1
vote
1answer
299 views

Exception\UnknownExtensionException: The module does not exist or is not installed

I get this error on my site Drupal\Core\Extension\Exception\UnknownExtensionException: The module does not exist or is not installed. in Drupal\Core\Extension\ExtensionList->getExtensionInfo() (...
0
votes
0answers
27 views

Adding button with Ajax callback in node using preprocess_node

I have my_theme and my_project. Also have a file called my_project.php. There I have two functions and in both of them I have ALMOST the same structure: function my_theme_preprocess_node__foo(&$...
-1
votes
2answers
337 views

Checking for the content type in html.html.twig

In the html.html.twig template, the task is to output different classes for the <body> tag, depending on the type of content. I know how to do this in the node template, but it doesn't work in ...
0
votes
1answer
28 views

How to change the view for a rendered product?

I'm learning Drupal Commerce with a Commerce Kickstart installation. I understood in part the way products are displayed, with variation types and content types. Have made some changes like visible/...
0
votes
0answers
33 views

Admin toolbar CSS broken by theme

I'm facing issue with Admin toolbar. Every time I create theme and define default style guide for typography eg.: ... h2 { font-size: 3rem; } p { font-size: 1.2rem; } ... Admin toolbar's CSS is ...
0
votes
0answers
57 views

Hide view's elements onfirst load, show them on filter click and reset it again by general data filter

Edit As my first question I made some mistakes, so I'm trying to keep it more clear and useful for other people. The scenario: I built a View showing nodes and contextual filters to have taxonomy ...
-2
votes
1answer
73 views

Updating 7 to 8, how to remove .less / scss files

I am updating a website from Drupal 7 to Drupal 8 and suddenly I see all these .less files influencing the style of the page. I found them in the theme's /srss directory (mytheme/srss/bootstrap/) ...
0
votes
1answer
35 views

Unable to retrieve checkbox values from a template file

I have created a checkbox option for a field. Category One Two Three Four This is the code I am using. {% for key, item in content.field_room_category if key|first != '#' %} <li>...
0
votes
1answer
33 views

Variable in file-audio.html.twig

I created the following preprocess function to add a value. function mytheme_preprocess_node__audio(&$variables) { $node = $variables['node']; $media_field = $node->get('field_image')->...
0
votes
1answer
28 views

How do I prevent the HTML markup in an item list from being escaped?

As you can see in the code below, I try various ways to prevent Drupal from escaping the HTML and passing the link tags to the output, including the use of '#allowed_tags' and the Markup class. None ...
0
votes
0answers
72 views

Is a block render array built with EntityViewBuilderInterface::view supposed to render full block template or only inner fields?

After rendering custom blocks in templates, I got this js error: Quick Edit could not associate the rendered entity field markup. What I've done so far : In order to render repeatedly custom blocks ...
2
votes
1answer
170 views

How to embed HTML and CSS in a custom form element?

This worked in Drupal 7 but isn't in Drupal 8. $form['covid-19'] = array( '#markup' => '<div style="border: 2px solid red;padding:10px;margin-bottom:10px;"><strong>Due to the COVID-...
0
votes
1answer
43 views

Sub-theme adding prefix to all block machine names

On my site, I have created a sub-theme of a sub-theme using this as a guide to set this up https://www.drupal.org/docs/8/theming-drupal-8/creating-a-drupal-8-sub-theme-or-sub-theme-of-sub-theme and it ...
0
votes
1answer
21 views

Upgrading to Drupal 8, custom theme not using referenced CSS file [closed]

I am upgrading a theme from Drupal 7 to Drupal 8. I reference .css files in mytheme.library.yml that do not seem to be getting pulled into the site. I've looked online and even copied sample coding ...
0
votes
0answers
45 views

Print a taxonomy term and url D8 views template

I am totally new to drupal 8. I have used d7 and i am migrating now. I have setup a view with 4 articles. I have managed to print out in a custom views theme my title image url {% for row in ...
0
votes
0answers
30 views

getUrlObject() returning empty proto object

I'm trying to follow this post to turn my menu tree into an array I can more easily work with. When I run my code and look at $filteredArray I get: title: *Name here* url_obj: {} has_children: true ...
0
votes
1answer
16 views

How can I render an image stocked in a custom module with an image style?

I'am learning Drupal 8, and I would like create a custom module who create a block to add share button. The link of this button should be an image who stocked in my custom module. I would like use an ...
4
votes
1answer
158 views

What is the difference between renderPlain and renderRoot?

I added a login form to a node with following code : function my_theme_preprocess_node(&$variables) { $node = $variables['node']; $variables['login_form'] = FALSE; $variables['username'] = ...
0
votes
1answer
27 views

Using variation values in a template file

I am building a site that uses Drupal Commerce 2 and I am attempting to build out the product details template. Our product has a variation (field_accessories) which is an entity reference to another ...
0
votes
1answer
52 views

How do I conditionally add a class to my page title within page-title.html.twig?

I have a boolean field within my Page content type called Hide Title. I need to conditionally add a class to h1's to visually hide them if this field is checked. I have the following within page-...
0
votes
0answers
41 views

Setting Views contextual filter values dynamically with Twig in Webform

I am attempting to embed a view in a webform whose contextual filter value is set based on a user selection. I have created a view of nodes with a contextual filter, and a webform with a select ...
0
votes
0answers
44 views

Access a page.html.twig template variable in another twig template using a preprocess function

Drupal core 8.8.3 Version Using a preprocessor function as below function subtheme_bs_preprocess_book_tree(&$variables) { $variables['page_id'] = code here to read the node.nid variable ...
0
votes
2answers
76 views

Geting values for multipart form elements using Twig

Whereever you are, I hope you're fairing well under the circumstances. To some of the hardest hit areas, we are thinking of you constantly. Webform Advanced Elements I am having difficulty ...
0
votes
0answers
12 views

How to change librarie's css from xxx.theme or hooks

I want to alter the path of the css of the mmenu library (jquery.mmenu.css and jquery.mmnenu.all.css) which are in (/libraries/mmenu/dist/jquery.mmenu.css and / libraries / mmenu / dist /jquery.mmenu....
0
votes
0answers
25 views

Strange behaviour in twig template

I am trying to render image in custom field.html.twig template but following snippet not working: {% for item in items %} {% if not loop.first %} <div class="image-gallery-image"&...
0
votes
1answer
70 views

how to create custom template for a product type in drupal 8 commerce

I want to have separate twig templates for each product type in drupal 8 commerce to customize them. is there any way to do that?
0
votes
0answers
110 views

Date range issues with timezones in twig

We're using date ranges for some events in an application. We're finding that when we use the date value and end_value independent of one another then the timezone is incorrect. For example, inside a ...
0
votes
0answers
22 views

Hiding the next page button in Webform after required question is completed

I am designing a webform (Drupal 8 webform 8.x-5.8) to serve questionnaires to patients and to ease the patients load of filling in questionnaires I would like to automatically advance the webform to ...
0
votes
1answer
66 views

Use page.html.twig template variable in another twig template

How do I call a page.html.twig template variable from the book-tree.html.twig template. Using kint, I have found the variable, nid as in the screenshot below: The 'nid' is highlighted, but it is the ...
0
votes
1answer
48 views

Extract email addresses from composite field type using Computed Twig

I am using a custom composite field type to gather multiple pieces of data from a user. This custom composite field type contains a field which gathers the email addresses entered. What I am trying to ...
3
votes
1answer
161 views

Why is libraries-override not removing assets?

My attempt to remove CSS and JS assets is not working. I have placed the following declarations in my module's *.info.yml file. But after clearing the cache, I still see the assets in the head of ...
0
votes
1answer
39 views

Basic page template

I am using Drupal 7 to create a page and a custom template for that page. I created a page from Content >> Add Content >> Page. In my theme /template folder I have created a file called page--my-...
0
votes
0answers
27 views

Spacing with inline links in TranslatableMarkup

I have a TranslatableMarkup string that has a link that is inserted in it as a variable. However this link comes without a space between the link and the previous word in the string. $message = new ...
0
votes
1answer
41 views

Load id of paragraph in hook_preprocess_layout using load($id) method

I want to load the paragraph id in theme preprocess. function theme_preprocess_layout(&$variables) { $ID = $variables['content']['#paragraph'] ???; "contents - protected 'id' => array(1) = ...
0
votes
3answers
57 views

Override templates for one view page or block

I am trying to figure out if there is a way to override the base templates for one view. I created a page with a view called 'Promotions'. I need to override the views-view-field.html.twig, views-view-...
0
votes
0answers
76 views

Issue with Access PHP array in display module

I am passing few parameters via ajax to custom module (fgs_api.module) and in returns getting JSON data ($results->data). I want to use/get that variable ($results->data) in node--xyz.tpl.php ...
0
votes
0answers
20 views

How do I create a template to display view fields [duplicate]

I created a view and added it as a block. Now what I want to do is to manage the way the fields are displayed. However, when I inspect the page, twig doesn't show me a template name that I can use to ...
0
votes
2answers
45 views

Can I somehow edit libraries.yml files from the backend using the admin panel?

In my Drupal project, we load custom CSS for some of our specific pages. Right now I do all of these modifications programmatically. But what our manager wants is to create it manually in the admin ...
0
votes
1answer
33 views

How to display an alternative text if the comments are closed for the node?

in my node type template, how do I display alternate text if comments are closed for the node ? {% if content.comment %} <div class="card mb-5 p-3 shadow"> {{ content.comment }} ...
0
votes
0answers
110 views

Can IMG URI be displayed in image.html.twig?

I want to include Magnific Popup in my site. The only thing that left to do is display the URL of the image in link wrapping the image field. I saw that image.html.twig modify the image of my ...
0
votes
0answers
21 views

managed_file FormElement submitting form upon file upload

How do i prevent managed_file(Browse Button) from calling submitForm function upon uploading file? I've added '#attributes' => [ 'submit' => FALSE, 'onclick' => 'return false' ] to no ...
0
votes
1answer
39 views

Place the footer AND the copyright blocks at the bottom of the page responsive [closed]

I installed Industrial Theme from Zymphonies and I am struggling to place the footer and the copyright (2 block layouts) at the bottom of the page. So, on my website it looks like that. I tried a ...
0
votes
0answers
66 views

Set display options for a json string in drupal 8 BaseFieldDefinition:

I have a field that stores a json string with keys and values in the database. I wish to format this output from my field definition display option to output the json string as a list. Is it possible ...
-2
votes
1answer
53 views

CSS not work after applying ajax

I have a problem with css after applying ajax. I have an exposed form that I stylized. Before applying ajax it is: id="edit-field-price-value-min" After applying it changed to id="edit-field-price-...
0
votes
0answers
26 views

Apply a theme to a custom field

I have a custom field with formatter which is currently outputting via field.html.twig I've modified the theme function to function mymodule_theme() { return [ '...
-5
votes
1answer
126 views

How to link to a file in twig template

I'm trying to link to a file in a view. I have a field in the view that outputs the link if I use it like this: <div class="product-cta-view-pdf"> {{ fields.field_notice.content }} </div&...
0
votes
0answers
36 views

how to print node object in drupal 8 [duplicate]

in drupal 7 we could use kpr() from devel module or php print_r() and var_dump() functions to print $node object in node.tpl file or hook preprocess node in purpose of debugging and finding a field or ...

1
4 5
6
7 8
208