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

Questions tagged [theming]

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

0
votes
0answers
20 views

Delete records from database pressing a button in twig

Drupal version: 8.7.x I created a module that retrieves meals based on the given ingredients. I display the ingredients with a delete button and the meals underneath them. However I don't know where ...
3
votes
2answers
335 views

Safe and elegant way to access nested entities via fields

I've seen a variety of approaches to access entity values in the theming layer. The code below is just a simple example using magic methods. It assumes all values are set - if any part of that returns ...
0
votes
0answers
23 views

How to move Js to header using hook_js_alter

Hi I am trying to move js from footer to header but I am getting exception like Exception: Invalid JS asset type. in Drupal\Core\Asset\JsCollectionRenderer->render() (line 90 of D:\Users\...
0
votes
1answer
20 views

Do custom theme suggestions execute on every page load and does that impact performance?

I've been working with Drupal for a little while now and one nagging question I've had is about whether or not logic in my *.theme or *.module files have any impact on server load. Let's say I have ...
-1
votes
1answer
30 views

Other twig syntax in commerce related templates

In some twig templates of the commerce modules, I can see the use of an alternate syntax: Ex. in commerce-cart-flyout-offcanvas-contents-items.html.twig : <% _.each(cart.order_items, function(...
1
vote
1answer
24 views

How do you prevent twig variable from last instance of template overriding those that go before it?

I am creating a module that will allow editors to display nodes as "cards" using the summary from the node for the card text and a field (field_hero) as a background image to the card, the user can ...
-2
votes
0answers
28 views

Selection, storing, caching of custom fonts

I would like you something about font paths and font caching in Drupal 8 (8.7.2). My aim is to use a custom font, without using the @font-your-face-module. Just for trying out, on my local ...
0
votes
0answers
24 views

custom webform time and date elements id's

Using webform, I have two "Date/time" elements with popup date and timepickers enabled. I have a jQuery script to calculate and display detailed time difference between the values (date and time) ...
1
vote
2answers
67 views

How can I print the vocabulary name instead of the referenced term in a node template?

Let's say I have a content type article with a field "taxonomy". The vocabulary is "fruits". The terms are "apple", "orange", "bananas" The article belongs to "orange". I can easily print in my ...
0
votes
0answers
45 views

Passing variables between theme preprocess hooks

I'm a newbie to Drupal 8 and PHP coding in general so I hope my approach is not too much out of the lines. I'm trying to theme some parts of my website by fiddling a bit with templates, what I need to ...
0
votes
1answer
34 views

Responsive Image Module is only selecting fallback image style

I recently tried implementing drupal 8's Responsive Images Module. I studied about it's basics and implemented according to the guides available online. But when i try to use it on any image on the ...
0
votes
0answers
35 views

Automated testing strategy for Twig templates [closed]

I am using Drupal 8 CMS for a media platform, which essentially uses twig templating engine. We are using component based approach, building small re-usbale building blocks instead of building the ...
1
vote
1answer
35 views

Passing an array stdClass Object from custom module to template

I’ve created some D8 custom modules which call rest API and and it’s working fine when I get simple array in my $response. In my controller, this is working : return [ '#theme' => '...
-1
votes
1answer
18 views

Drupal theme error. functions from add on libraries are not included when running my custom script [duplicate]

I'm trying to load a javascript function in my custom script with jquery and materialize. When the script load it says Uncaught TypeError: $ is not a function and sidenav() is not defined. My ...
-1
votes
1answer
26 views

Retrieving value of paragraph type with entity reference revision through preprocessor

I have created a paragraph type which has field of type entity reference, link, plain text. Now I want to fetch the values present in these through the preprocessor.paragraph.inc and display it in ...
-5
votes
0answers
21 views

Drupal 8 Theming Twig

I have made a page view in table format list of some media articles having description and link as field Now I want to fetch the page view field in my page--front.html.twig. How to do. I want to show ...
0
votes
0answers
23 views

How to get file fid value in paragraph and view templates

Hi i am trying to access file fid value in paragraph twig template file but cant access it. Though I can print file uri but I need to access fid of the file Here is my code in paragraph.pdfdocument....
0
votes
1answer
23 views

Is it possible to create/manage Roles using a .yaml file?

I'm trying to secure some REST URLs that are present in my ApiController.php so that users with certain privileges can access these REST APIs. I created some users and assigned them with some Roles ...
0
votes
0answers
14 views

Displaying Field Collection Items of a Commerce Product in Twig

I'm trying to display field values within a field collection for a commerce product. In my product template file I'm simply outputting {{ product.field_components }} then using a separate field ...
0
votes
0answers
9 views

How to access the value of another field in the same field collection from a field template file?

In Drupal 7 I've customised a file download field in a template file: field--field-downloads.tpl.php Within the same field collection (using the 'field_collection' module: https://www.drupal.org/...
0
votes
1answer
23 views

How can I render an HTML table in a block?

i have created a module for showing third party API data here is some data returned from that API {"ObjectId":43,"ObjectName":"MEGA MELA","ObjectTitle":"Event Created by API","ObjectDescription":"...
-1
votes
2answers
37 views

How to Restrict some special character in password field

I'm very new in Drupal, I would like to restrict some special characters from user password field Is there any way to edit configuration of core modules i'm trying to create preg_match modules . i ...
0
votes
0answers
17 views

How to add an additional link into node links array programatically?

I would like to add a additional link into the links list of my node-type teaser-display (where "write a comment", "read more" link are located). Also I would like to pass some tokens (token module ...
0
votes
1answer
24 views

How to add unique class to each checkbox elements

I am displaying checkboxes using form API in Drupal 8. For functional and theming purpose I need to add unique custom class to each checkbox element. Is there any way to add classes to each checkbox ...
0
votes
1answer
34 views

Unable to load css files using ['#attached'] or drupal_add_css

I'm attempting to attach several css files to a Drupal 7 module. All files have identical read/write/execute and owner permissions. I haven't had trouble with one of the three files but I can't get ...
0
votes
0answers
23 views

Add a custom reset button to a view page

We have a myview which as as a page display where the path setting is set to /mypath. On this page, we have an exposed form (exposedform_myview_page1) for searching the Article titles and a facet ...
1
vote
2answers
54 views

Fetch view results from mymodule_preprocess_page hook

We have a View page that is coming from myview. Using the header setting in the view we have added @total results already, which displays in the views-view--myview--page-1.html.twig using the {{ ...
-3
votes
0answers
9 views

Hero image slider returns to first picture after downloading a picture from the slider

My website uses a hero slider and if you are on, say, the 4th bullet and select download, after the image downloads, the slider doesn't stay on the 4th image, but rather goes back to the start of the ...
0
votes
1answer
24 views

How can i add ajax callback to checkbox in drupal form?

I am using taxonomy manager module I want to add ajax callback to checkbox tree view for checkbox is checked condition but it is not working can some one please suggest me. I have modified the code ...
-2
votes
0answers
22 views

How to prevent generating drupal admin menu id?

For few days I was styling in CSS a large menu, and I almost finished, but now I see that I have a huge problem. I was styling logged as admin, and I was using to style elements ids of them: #rm-no-id-...
1
vote
1answer
32 views

How do I force Twig output from my custom module, instead of from the theme? [closed]

I'm new to Drupal, I create a module including block and twig. I want to call out my twig(modules/custom/footer_block/src/templates) and store data in there when execute build() in block. However, it ...
0
votes
1answer
55 views

I want to build multidimensional array at Twig

I want to build multidimensional array at Twig. In php $attributes['attributes']['class'] = array(); $attributes['attributes']['class'][] = 'innerTab'; $attributes['html'] = TRUE; Same thing ...
1
vote
0answers
12 views

Need to add SKU to order confirmation email - Commerce 2

I have been able to customize the order confirmation email twig file for a client to some degree, however when it comes to adding the SKU for each item ordered I cannot find a way to have it populate. ...
0
votes
1answer
48 views

How to get fields in StylePluginBase

i´m building a new nap view style. I get the map shown correctly, but only without the data of the view :-(. class OpenlayersViews extends StylePluginBase { /** * Whether the display allows the ...
0
votes
1answer
51 views

print data to twig file from custom form submit via controller

I have created a custom form, and I'm passing data to twig file from submitForm function as follows public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->...
-3
votes
1answer
24 views

How to use the Message Template?

I have Drupal 8 with the Message module. I created message templates using drupal 8 but I prefer to use TWIG. In Drupal 8 my code works, but when I put it in TWIG, the tokens do not work. How to ...
-1
votes
0answers
15 views

Confirmation popup Box according to a condition on submit button

I am using Drupal 7. In my list I have 2000 subscribers. Now I want a confirmation box before executing the form. The only issue is If I have more than 20 users I want the confirmation form to ask ...
-1
votes
0answers
19 views

Create a template file just for the first level

I need to create a template file just for the parents of taxonomy terms. First of all I don't know if the same as drupal 7 in 8 I should write this code in template.php file or not. In the second ...
0
votes
1answer
28 views

Raw Field Value in Views

We have a content type that has a Video Embed Field. In this field, we simply enter youtube or Vimeo url. In a custom view we are trying to display the raw value of the field. Since this is a Video ...
1
vote
2answers
106 views

Custom module javascript Drupal.behaviours doesn't seems to load

I have a custom module which has a javascript file. Here's the content of the javascript file: (function ($, Drupal) { Drupal.behaviors.promotionalOverlayBlock = { attach: function(...
0
votes
0answers
24 views

How do I enable template suggestions debug output only for administrator users?

I know you can turn on Twig template suggestions. Is there a way of doing this on a production environment, only for administrator users, to avoid everyone can see the templates viewing source code? ...
0
votes
2answers
31 views

How to display article metadata in a custom div?

Metadata (publication date, author's name...) is normally displayed in the "Content" part between the "articles" tags. I have created a new region "titre d'article" in which I would like them to be ...
0
votes
0answers
6 views

How can I attach a css file within the ckeditor iframe [duplicate]

I need to attach a Drupal library but only in iframes that ckeditor uses. I've noticed there appear globals libraries, but I only need to add this in a specific case. Also, when I clear the cache, ...
1
vote
1answer
46 views

Possible to theme the form's elements with own twig?

I was thinking to get twig outputs so I could use these twig variables on a form.html.twig such as below: <div class="row"> <div class="col-md-6"> {{ form.name }} ...
0
votes
1answer
27 views

Drupal 8 Theming

I am beginner with drupal 8 theming. My Question is: I have created a custom content type name project_images for making carousal SlideShow. It consists multiple images as a field. Now I want to ...
0
votes
1answer
34 views

How do I print an image field value in views-view.html.twig?

It seems I'm able to print text field values with {{ view.field.field_example.getvalue(view.result[0]) }}, but this same method doesn't work for image fields. Please help.
0
votes
0answers
22 views

Programatically load facet

We created a facet, facet_type (machine name) that is connected to the content datasource. There is a view that filters by content datasource and is called articles page (www.example.com/articles). We ...
0
votes
1answer
87 views

Strip html tags in preprocess hook

We have a mytheme.theme file that has a mytheme_preprocess_node(&$variables) function. Within this preprocess hook, we would like to remove all HTML tags within a formatted (long) field. The goal ...
1
vote
1answer
50 views

How do I pass variables into Twig template?

In my preprocess function I have variables with the route name and route parameters: function my_theme_preprocess_node(&$variables){ $variables['route_name'] = $route_name; $variables['...
0
votes
2answers
58 views

How do I stringify objects or at least get a string value?

The item.content for my field item is 'active'. However, when I use a comparison operator as seen below, it never equates to True but always False. I thought maybe some spacing issues was the reason, ...