We’re rewarding the question askers & reputations are being recalculated! Read more.

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
2
votes
3answers
473 views

Get node ID or URL in Twig on field level

I have a field value, which I would like to link to the content (to the node itself, using it in a teaser). How can I get the URL or at least the ID on field level, to create that link?
1
vote
1answer
22 views

Display summary + read more links if body content is long, otherwise display body alone

We have a content type which has a customized template. In general, the body content of these nodes is short -- one to two sentences at most. In some cases, however, the body content is a paragraph ...
0
votes
1answer
27 views

Display long text fields as type text input not as textarea on node forms

I have some fields which are configured as long text fields, which I need to display as <input type="text /> instead of <textarea></textarea>. I'm trying to find the correct naming ...
0
votes
1answer
45 views

Overriding radio button rendering

I have a List (text) field on a comment type. This field is required and only one option may be chosen, so a radio button is how it will be rendered. I would now like to change the way the radio ...
0
votes
1answer
15 views

Is there a field tpl for body and/or title fields?

I need to add some data- attributes and I am hoping to change it for the body and title fields on article content types. Do the title/body have tpl's that I can modify to add these? Or another method ...
1
vote
0answers
42 views

How to display the parent node or product of a comment?

I installed the Message module on my site. I created a custom module that created a message when a comment is created. https://imgur.com/a/4OLhGlL How to display the parent node or product of a ...
0
votes
0answers
33 views

Alter a Field Collection display order inside a FieldCollectionHook

I have been stuck in here since yesterday and I'm starting to run out of ideas. I have a Field Collection that contains 2 fields. The first one is a multiple taxonomy term, and the second one is a ...
1
vote
1answer
155 views

Change field label used in node display

I have a custom content type in Drupal 8.6.x. I want to be able to change the text used for a field label based on the value of a taxonomy term reference in the node. For example, I want to change ...
0
votes
1answer
12 views

Views Add Link to product field missing

I have a search results View which list the (Commerce) products. I show the title and the image fields. I those fields to wrap in a custom <a> link tag. When I am adding fields, I miss the 'Link ...
1
vote
1answer
60 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....
0
votes
2answers
43 views

How to achieve clean HTML markup?

If you visit official website of Dries Buytaert https://dri.es/ and look into the source you will see very clean and minimal markup with no unnecessary tags and classes, eg: When I create a simple ...
0
votes
1answer
155 views

Format date field in twig

Date field having multiple values. Need to format the output. {% for item in items %} <div{{ attributes }}>{{ item.content|date(format="F j, Y") }}</div> {% endfor %} item.content ...
0
votes
2answers
53 views

CSS changes not updating

Basic caching settings all off: settings.local.php is loaded: Bottom of settings.php: if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) { include $app_root . '/' . $...
1
vote
1answer
21 views

Remote attribute in mymodule.libraries.yml

When creating a library, I noticed there is an attribute remote that can be added. I cannot really find any good documentation as to what it is for nor does it seem like it is required. Questions: ...
1
vote
1answer
63 views

Add theme color palette picker

I have a multisite in Drupal 8 eg. same codebase, differrent db. The client is asking for different color scheme for each subsite. I was thinking of implementing somehow Bartik's color picker, but ...
0
votes
3answers
50 views

Attach different CSS classes to first and second link

I have a Paragraph type 'Call to action' with one link field field_link. I have another Paragraph type where I call the 'Call to action' paragraph as an Entity reference revisions field. With Allowed ...
1
vote
1answer
17 views

Render form element of type text_format, keeping WYSYWIG format

In Drupal 8 I have a form element fo type text_format, and I need to render it in a twig, but keeping the same format was entered in the WYSYWIG editor. I need to know how to render this element form, ...
0
votes
0answers
39 views

How to add header and footer to pdf generated via Entity Print module?

Using the Entity Print module (with the library wkhtmltopdf) for exporting a content to PDF, how can header and footer be added to the each page of the PDF? There are setHeaderText($text, $alignment) ...
0
votes
1answer
151 views

Anchor links to paragraph content

I have some drupal 8 sites that make heavy use of the Paragraphs and Bootstrap Paragraphs modules. Some of my users want to be able to create anchor style links to specific paragraph items on pages. ...
0
votes
0answers
38 views

Setting a field value in a hook_preprocess, then the field has its original value in twig?

Inside of a hook_preprocess_hook, I'm setting the value of a field as follows: $mainTab->get('field_url_alias')->setValue($url) I've verified that this value is actually being set correctly. ...
1
vote
1answer
60 views

Getting literal ampersands from summary field in a view of fields

I have a view where we are using the Body Summary field. I got a bug report that an HTML entity, &amp;, displaying, where they wanted a literal ampersand. When I updated our existing view, ...
0
votes
0answers
18 views

Ajax loader when facet is selected

When we add a facet block to the page, a filter is selected and the page starts to load the results. However there is no loading icon or indicator the change is being applied. When we check the page,...
0
votes
1answer
55 views

Node field not sanitize on render

I have a form for users who want to add new content on my Drupal 8 website. I render node field on a twig template : {{ node_field_title.value }} But field are not sanitized by Drupal. Is it the ...
1
vote
2answers
225 views

Wrap a link around a block in Twig

I have a block and I’m trying to wrap a link around it: {% block paragraph %} <div{{ attributes.addClass(classes) }}> {% block content %} <a href="{{ content.field_link.0['#url'...
0
votes
1answer
18 views

Changing a menu link used in the sitemap module but not in main nav

We are using the Sitemap module for creating a sitemap generated from three menus (Footer, Main nav and a 3rd arbitrary one). In the main nav we have a placeholder LI element which we use to insert a ...
0
votes
1answer
17 views

Adjusting Main Menu Tabs

I am able to add tabs in the Drupal 7 Main Menu however I want to adjust spaces between these tabs.How does one adjust spaces between tabs. Thanks
0
votes
1answer
34 views

Need help with how custom fields are displayed by article.html.twig file

Noncoder here. After not poking my head under the hood of any CMS in years (not since Drupal 5, I think — and I wasn't very good at it even then), I'm working on a portfolio site. I suspect this ...
0
votes
1answer
97 views

Render image field with custom image style in custom block template

This is basically the same question as this, but I can't get the technique to work in a custom block type template: https://drupal.stackexchange.com/a/219052/71100 I have a custom block type called ...
0
votes
1answer
81 views

Checking for string in variable fails in twig

I'm working on a twig template for use with a commerce product. Each product has a term applied to it like "Green Ball", "Yellow Ball", "Red Block", and "Purple Block". I'm trying to take the ...
1
vote
3answers
132 views

Body Summary field showing literal ampersand character code in view

I have a Drupal 8 site where we've created a view, and decided to use the summary field instead of the trimmed body field, so that we could have more control over it. However, I got a bug report ...
-3
votes
1answer
21 views

Today is in list of dates

Trying to check if variable 'today' is in a list of dates in Views Conditional Field. Both values print out nicely. Today (var php): 24/06/2019 List of dates (var field_dates): 24/06/2019, 25/06/...
0
votes
1answer
33 views

Target individual items of a multi-value field in my page template

I created one field for an image and In the field setting, I made allowed number of values to 2 (please find the attached screenshot ) So my question is, how can I add both the images in a different ...
1
vote
1answer
158 views

Templates aren't called in custom module?

I am trying to add templates for the paragraph in the custom module. It invokes only the paragraph.html.twig. In theme suggestion, paragraph--example-ch-hero-panel.html.twig is given. I am using the ...
0
votes
0answers
10 views

maintenance-page.tpl.php is replaced per page--node.tpl.php

My template maintenance-page.tpl.php or the default maintenance-page.tpl.php is replaced per the page--node.tpl.php of my theme. I have check in my setting.php $conf['maintenance_theme'] = 'Mytheme';...
0
votes
1answer
29 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
24 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?
2
votes
1answer
62 views

Remove the cache for a particular Twig file

I'm showing the name of the currently logged-in user in header, using \Drupal::currentUser()->getUsername(), but it's showing an already cached page. I know I can disable the cache for a ...
0
votes
0answers
49 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
407 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
24 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
46 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 ...
0
votes
0answers
35 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
201 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
87 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
65 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
112 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
23 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
369 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 ...