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
24 views

Link module output with content type

I am confused on how to output links from a content type into a list in HTML. Currently I have the following code. <div class="lenders-block-content clearfix"> <ul> <?...
0
votes
1answer
20 views

Custom CSS and JS that would load only for a content type's view mode

I am trying to load a custom css and js on my content type's view mode. Can this be achieved in drupal 8?
1
vote
1answer
45 views

Remove the cache for a particular Twig file

I'm showing currently logged in username in header. But it's showing already cached page. I know, I can disable cache for particular page in module using \Drupal::service('page_cache_kill_switch')-&...
0
votes
0answers
33 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 ...
7
votes
2answers
399 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
24 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
22 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
42 views

Other twig syntax in 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
31 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
29 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
27 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
88 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
51 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
35 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 ...
1
vote
1answer
41 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
20 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
46 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 ...
0
votes
0answers
26 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
19 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
25 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
39 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
18 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
30 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
37 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 ...
1
vote
2answers
58 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 {{ ...
0
votes
1answer
26 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 ...
1
vote
1answer
34 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
58 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
18 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
49 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
52 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
28 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 ...
0
votes
1answer
34 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
111 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
43 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
7 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
28 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
36 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
1answer
105 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
57 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
60 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, ...
0
votes
0answers
22 views

What would be the correct twig naming convention to override a table specific to a view page

can someone tell me the naming convention for a table in a specific page view please I have views.view--custom-page.html.twig to over ride the page I assumed it would be views-view-table--custom-...
0
votes
1answer
57 views

How to print the relative url or node id for each referenced node in twig?

I am using paragraphs to render a number of nodes on a page. The nodes are obtained through an entity reference field called 'field_nodeslist' in my cards paragraph type. The cards are then rendered ...
0
votes
0answers
19 views

loop through paragraphs ID's in node template [duplicate]

In a custom twig template for content type "legal", I'm trying to loop through a 3-field paragraph called "legal_section." It's referenced by my content type, using an entity reference field called "...
0
votes
1answer
32 views

Override view-list and get items properties

I'm currently working on Bartik theme and i'm trying to create a custom template for the Content-Recent block available in Drupal 8 For your information, i would like to create the following block ...
0
votes
1answer
41 views

How can I add folders to my template directory and have Twig find them?

I was listening to a Drupal Developer on youtube and one of the suggestions he has, is that when you go into a template folder, create some subdirectories for easier management, like this: Templates -...