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
1 vote
2 answers
2k views

How do you override the add or edit node for a particular content type

I want to format the editing or adding form for the article content type. i.e. node/add/article path and editing the same article. I copied over the node-edit-form.html.twig template from core/modules/...
2 votes
2 answers
2k views

Altering nodes title value

I am trying to alter the title of my nodes to prevent URLS appearing in any title. This is the code I am using. function mytemplate_preprocess_node(&$variables) { $node = $variables['node ']; ...
2 votes
1 answer
901 views

Display field collection items by using twig

I'm using the field collection module in Drupal 8 to encapsulate event informations so I've got a field collection with six sub fields (place, starting time, etc.). In my twig template field--field-...
2 votes
1 answer
479 views

Add CSS class to view image_field in twig

In my custom view fields twig file views-view-fields--search--product_result.html.twig I try to theme my view item. {{ fields.field_images.content }} <h5 class="card-title">{{ fields.title....
1 vote
1 answer
1k views

How to display custom fields of taxonomy in field twig

In my content type for Event, I have an entity reference called Speakers which refers to a taxonomy called Team Members. It's set to multiple so I can say which speakers belong to my event. On ...
1 vote
1 answer
3k views

Add a span/class to a field

I've found a way to add a style to a region. The link is /admin/structure/ds/styles. I've found a way to specify a style for my Title. We can choose the "class" attribute of title property. Howe ...
0 votes
1 answer
448 views

How to create a responsive views block in bootstrap?

I created a content type with one field collection field using Field collection module which accepts up to 4 values. Field Collection: Field collection field has 3 fields (text1(40 char), text2(255 ...
2 votes
2 answers
2k views

Theming a views field output using views-view-fields.html.twig

I am trying to customize a views output on a view page to wrap the fields in custom markup. I need to group a set of fields to achieve the desired layout like so: Example: <div class="wrapper"&...
1 vote
1 answer
4k views

Render entity reference field with link in node template

I have a content type with an entity reference field to select a user. Now I would like to render this field in the node template so that the field links to the user profile. I set the format of the ...
0 votes
1 answer
975 views

How to render entity reference data in field template?

I have a field collection with adding multiple items. In each item there is an entity reference field with multi-selection of contents. I can render entity reference content by target_id using ...
5 votes
4 answers
2k views

Switch theme by content type

My company has just purchased a Drupal theme to apply to some new pages they want to add to an existing site. This theme is different to the existing theme of the site. They want to create a new ...
1 vote
1 answer
429 views

How to remove custom block parent div's?

I have created custom block in my custom module. I have created block template file into module templates folder. Custom block content coming successfully as per given in block__MODULENAME__dummmy_xyz....
0 votes
2 answers
500 views

Add specific CSS class to form elements from the address field

I try to add a custom css class to a form element inside my address field for e.g the postal_code field and another class to the given_name and family_name field. I tried it with a ...
0 votes
1 answer
528 views

Create a button with an icon in render array, that can be themed by arbitrary contributed themes

Drupal 8 does not use HTML button tag for creating buttons, it instead uses the input tag to create buttons. This works fine for most part, except for buttons which include an icon gets messed up by ...
0 votes
1 answer
667 views

Adding class to nested UL in menu

I'm creating my menu using view along with Bootstrap to create a mega menu style navigation. I'm having a problem with the nav showing expanded at times when you come to the site and or refresh. not ...
0 votes
2 answers
722 views

How to render language select block in page template?

Background information: I used the following script to list all the twig blocks: drush ev "print_r(array_keys(\Drupal::service('plugin.manager.block')->getDefinitions()))" and when I tried the ...
11 votes
2 answers
4k views

How do I use a custom twig template with a render element?

I am fairly new to Drupal 8 module development, so I decided to follow a tutorial at https://docs.acquia.com/articles/drupal-8-creating-elements-theming-elements-and-managing-frontend-libraries, which ...
2 votes
2 answers
486 views

Theme developer module crashes the whole site when enabled, how to fix?

I'm working on a clean Drupal 7.x installation, downloaded Theme developer and its dependent module simplehtmldom API( another required module for Theme developer) using drush. I found out that ...
0 votes
1 answer
673 views

Alter title link in taxonomy view mode

Under /admin/structure/taxonomy/my_vocabulary/display/entity I've got a view mode "entity". For this view mode, I would like to alter the way the link in the title field is built (the title is ...
0 votes
1 answer
457 views

Pass data to hook_preprocess_html from custom module

I'm trying to create a custom Drupal 7 module where it renders a custom page template. I want the data on /animals and /animals/getanimal to be in a custom HTML template. After much searching and few ...
0 votes
0 answers
32 views

How to use microsoft graph toolkit within a custom module?

I am creating a custom module and want to use microsoft graph toolkit, specifically the file-list component (https://learn.microsoft.com/en-us/graph/toolkit/components/file-list). I've created a ...
0 votes
1 answer
748 views

How to access a parent paragraph twig file from a child node twig file?

In my bootstrap theme, I am trying to make the id of the paragraph the same as an attribute for each of the child nodes, so an accordion will work properly. I have tried looking at doing it through ...
1 vote
3 answers
9k views

Get path of uploaded file inside a Twig template

I've created a teaser template like this node--type--teaser.html.twig. Within that template I want to conditionally create a link to a file that was uploaded via the field field_pdf. How do you ...
2 votes
1 answer
459 views

Add inline widget to product display

I am trying to integrate our Drupal 7 Commerce install with Digital River's where-to-buy widget. All I need to do is add a little JS to the product page, with a script variable set to the product sku....
0 votes
1 answer
782 views

Use form_alter to change description under reset password field for user_pass form

I'd like to change the text below the reset password field. I took a look at this answer, and it talks about changing the button, but I need a bit of help to change the text. Here is the debug output ...
0 votes
1 answer
671 views

Manage Display Field Label not changing: inline does not work

I have the same problem as question 212176 and discovered it has to do with CSS. I have 2 (local) sites both with module ds enabled. I configured in both a field where I want the label and the value ...
1 vote
1 answer
502 views

Blog monthly archive block - list of posts grouped by year then month

See the implementation on this guy's blog: http://deglos.com/blog YEAR -- Month -- Month YEAR -- Month -- Month Anyone know how this was accomplished?
1 vote
1 answer
644 views

Adding two contextual filters (Content : nid)

I want to display two type of contents : News and Events. So I added them in the filters criteria. This works great. Now I want them to be further filtered on the basis of the category the News and ...
2 votes
1 answer
274 views

How do you override a module's template from another module?

I'm trying to override an email template of the webform module. The project is headless so we don't have a custom theme, and we'd like to stick with the Adminimal contrib theme. However, we do have a ...
0 votes
1 answer
514 views

How to inject code into node body after x paragraph

Trying to figure out if there is a way to inject code after the first or second paragraph on a node. More specifically I am trying to inject an Adsense ad. So far I haven't been able to find a ...
0 votes
2 answers
547 views

Is there a reliable way to show Drupal messages from JavaScript?

I need to show status messages (the kind typically shown by drupal_set_message()) in my module's JavaScript code. How can I do this reliably, such that the theme and placement of the messages remains ...
0 votes
1 answer
398 views

Override Profile2 with account fields and values

I have created a new Profile Type with Profile2 module. Now I want to override it, importing three existing fields from my original Account (First Name, Last Name, Email) with their own values (that ...
1 vote
1 answer
629 views

Display Entity Reference field twice, with different display modes

I have a content type (Type A) that has an Entity Reference field to another content type (Type B). Type B has 3 fields and 2 display modes. Display A shows two of the fields, Display B shows the ...
0 votes
3 answers
3k views

Drupal 8 theme showing Uncaught TypeError: $(…).find(…).once is not a function in console

New to Drupal 8. I've created a demo theme. The .libraries.yml file is below: global-styling-and-scripts: version: VERSION css: base: assets/css/font-awesome.css: {} assets/css/bootstrap....
0 votes
1 answer
697 views

Print rendered field in views-view.html.twig

I try to render a custom node field in a views-view.html.twig and it works, the only thing is that i get the machine name and not the formatted name. Please can somebody describe me what i am doing ...
0 votes
2 answers
649 views

Add CSS classes to theme function

I'm implementing hook_theme() in a custom module. function monitor_chart_theme() { return array( 'chart_monitor' => array( 'template' => 'monitor_chart', 'variables' => ...
1 vote
2 answers
3k views

Rendering a nested Paragraph's field using Twig

We are using the Drupal 8 Paragraphs module and are have a Paragraph which contains a Paragraph type field, called "Steps" (machine name fs_steps), allowing editors to add a number of "Step" ...
1 vote
1 answer
1k views

Can't seem to format date in twig from UTC to User's locale

I am trying to format the date field from an event content type that I've created so that I can pass the date into an event exporter that creates events in calendars such as Google, Apply, Yahoo, and ...
0 votes
1 answer
506 views

Have Views based Taxonomy Term page use term description for title

I am using a view to replace the standard Taxonomy Term page (turned on the standard one in Drupal 8.x). I want the Title of the page to be changed from the Name of the term to the Description of the ...
0 votes
1 answer
483 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
1 answer
394 views

Using Twig in global custom text to check for a specific content type

I am filtering for two content types to display in a view: Artwork Page and Cover Page. I want to change the HTML markup for Cover Page. I have researched and tried many field names for Content Type, ...
0 votes
2 answers
56 views

Can't get real field value from paragraph

I need to get value from exact paragraph type in paragraph reference field in node, so I can use it in Twig. Here's my current code: function my_theme_preprocess_field(array &$variables, $hook) { ...
1 vote
1 answer
672 views

Access to core comment preprocess variables in a custom comment layout twig template?

In Drupal 8 I have a custom comment type and when I use the default core comment.html.twig to render the comments then variables like 'new_indicator_timestamp' and 'parent' get rendered as expected. ...
0 votes
1 answer
407 views

Custom user_register_form for Auto Assign Role registration pages

I'm using a function[a] to get custom templates to work for all pages, including role registration pages set by Auto Assign Role. By setting the role registration path to user/register/<rolename>...
0 votes
1 answer
2k views

Using webform-form-[nid].tpl.php to change default template

On drupal 7, using webform 7.x-4.11, I am trying to modify the template of a specific webform. So, in /web/themes/bartik/templates (I am using bartik theme) I created a file named webform-form-23.tpl....
2 votes
1 answer
2k views

How do I add a script just above the closing body tag?

How do I add a script on Drupal 8 site/app just above closing body tag? Vendor provided some JS in the following form: <script> ... code </script> Asked me to place immediately ...
1 vote
1 answer
397 views

Using theme_preprocess_node i'm trying to add a class to all images on the page

My code below is not working and i'm not sure why. I've tried a few variants. according to the KPR variables output, the image I'm trying to access is here. $variables['field_about_image'][0] i ...
1 vote
1 answer
362 views

JCarousel Views - Multiple Rows

My problem is related to Drupal and the use of the JCarousel module for my views. I'm having a few problems with this, namely in getting a jcarousel like view style but with 2 rows instead of one. ...
-3 votes
2 answers
60 views

Update entityManager()->getViewBuilder from 5 year old site?

I have a Drupal 8 module which hasn't been updated for 5 years. I m trying to update to current version of Drupal. The error I get is Error: Call to undefined method Drupal::entityManager() The code ...
1 vote
2 answers
526 views

Passing variables from hook_mail to cutom twig template

Custom twig template into hook_mail() $body_content = array( '#theme' => 'mail_body_content', '#node' => $node, ); I would like to access to node Entity and display value into the twig ...