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
0answers
5 views

Problem with tagging a biblio reference in a book page using [bib]citekey[/bib]

So the problem I am having is it does put the reference number and show the whole biblio in References beneath the body. But inside of the body it also shows the details of the biblio cite such as the ...
1
vote
1answer
24 views

Prevent clubbing of server side error messages on top

I have inline form errors module enabled on my drupal 8 site. The server-side errors that appear on form submission are appearing as clubbed together like below: How to change this error language and ...
0
votes
0answers
23 views

How can I use an if-else-statement to conditionally display or hide field collection items?

I have a field collection with 3 fields. The max limit of the filed array is 3 in other word [0-2]; Filed collection name: - television field collection items: brand, size, color. What I want to do ...
0
votes
1answer
20 views

How to add extra eventlistener to menu object in attached library

This is my first Drupal 8 project and I'm running into a problem figuring out how to attach an extra event handler to an object. I am working on a custom theme using Radix as base theme. I am using ...
0
votes
1answer
21 views

How can I add a pager to the top of a forum?

I am using the standard forum module that comes with Drupal 8. The problem is, when I view a forum node, it shows the pager the bottom. I want the pager to also appear at the top. The closest I've ...
-2
votes
0answers
17 views

How can I calculate the total value of two fields in webform

Here is my scenario: a user calculate a price for house design he/(she) can select in a drop down called type of house : apartment, office, standard home, and I want to if to specifies type of ...
0
votes
1answer
11 views

hook_custom_theme() works except if a user submits a user form with mismatched passwords. Then they get served the admin theme

Title basically. My hook_custom_theme() has been working for ages and I only just realised the admin theme is being served for an error when saving a user form ie. mismatched passwords. A snippet ...
2
votes
1answer
56 views

Variables injected or set in a Twig file are undefined after the first position of an entity reference field

I have a Paragraph setup that has an entity reference field allowing an editor to select multiple nodes to use in a display. Based on the count of nodes, I want to trigger a class. I figured a way to ...
1
vote
1answer
57 views

How to get entity Translation's title in Twig

i am trying to get row title -node title- in my custom module with template_preprocess_modulename_view($variables) and views-modulename-view.html.twig with using row.content['#row']._entity.title....
1
vote
1answer
28 views

Displaying associative array data in twig

Using drupal 8.7.x I have an associative array that is returned to twig. However I can't seem to get the data displayed. Associative array: array_push($mealsArray, ["meal" => [ ['...
0
votes
0answers
27 views

Is it possible to execute a function on a user object in Twig?

You can use hook_entity_load to add fields to the user object like so: function mymodule_entity_load($entities, $type) { if ($type == 'user' ) { foreach($entities as $e) { $e-...
0
votes
0answers
22 views

How to specifically define name and value attributes for checkboxes form element? [on hold]

I am trying to build a form parallel to an existing 3rd party html newsletter form (from CleverReach). The final checkbox markup needs to look like this: <input name="1130400[]" value="lorem ipsum"...
2
votes
3answers
65 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
18 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 ...
-2
votes
0answers
17 views

Changing Bootstrap 3 mobile menu breakpoints

I would like to change the width the mobile menu in the bootstrap theme appears instead of the desktop menu. I have my own subtheme created from the bootstrap base theme. Currently the mobile menu ...
0
votes
1answer
17 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 ...
-2
votes
0answers
40 views

How to display the rendered entity of a reference field in a template? [closed]

I have the Message module installed on my site. I created a message template for the new node created in my sub theme. Nodes have a display mode called message_activity_stream How to display this ...
-2
votes
0answers
25 views

Get $tempstore inside Twig

I'm creating a module my_module, I want to tempstore a variable and get it inside a Twig template. Here's my controller: $tempstore = \Drupal::service('user.private_tempstore')->get('mymodule'); $...
-1
votes
0answers
32 views

How to display message author info [closed]

I have the module Message installed on a Drupal 8 site. I want to display the information of the author of a message but I can't figure out how to do it. How can I display: the url of the account of ...
0
votes
1answer
32 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
12 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
40 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
32 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
43 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
41 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
36 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
28 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
35 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
16 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: ...
0
votes
0answers
19 views

Printing variables inside template vs printing views performance for logged in user / uncached pages

What solution si better regarding to performance for logged in users or on uncached pages (site cache is turned off). My content type contains around 70 fields: Printing fields inside node template (...
1
vote
1answer
26 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
44 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
9 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
19 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
32 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
29 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
32 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
11 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
52 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
75 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
15 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
13 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
33 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
23 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 ...
-1
votes
0answers
31 views

How to print the file name in Twig [duplicate]

I have title and filename in {{item.content}} then i tried to iterate title like {{ item.content['#title'] }} Which is working well.similarly i tried to iterate filename like {{ item.content['...
0
votes
1answer
35 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
87 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
29 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 ...