Questions tagged [theming]
Use it for questions about rendering or modifying the HTML markup produced by a module/theme.
10,461
questions
1
vote
1answer
11 views
Newbie Taxonomy and Content Question
I'm new to Drupal (having used Perch CMS and PHP for years). Forgive me if I bumble the terminology a bit. I've been furiously going over documentation and tutorials. Sorry in advanced for being ...
0
votes
0answers
14 views
How to select the user desired crop in the “Manage Display” section of a paragraph type for an image field?
I'm currently using ImageWidget crop to give some aspect ratios for users to pick when editing content (1:1, 1:2, 2:1, 2:3, 16:9), that is properly set up in the "Manage Form Display" ...
0
votes
0answers
25 views
Adding a prefix and suffix
I'm on a project that involves me having to add a prefix and suffix to the admin toolbar (to the highest level, div#admin-menu; the admin_menu_toolbar module is enabled) on a Drupal 7 site. The goal ...
0
votes
0answers
48 views
How to create template suggestion for image like IMAGE--BLOCK-TYPE or IMAGE--FIELD-TYPE
I'm struggling to make template suggestions like IMAGE--BLOCK-TYPE or IMAGE--FIELD-TYPE.
I have three different block types(image1, image2, image3) with one image field(field_image_1, field_image_2 ...
1
vote
0answers
36 views
How do I change layout?
A disclaimer first: I am a professional medievalist, not a programmer or a front-ender. I have some front-end knowledge, but not a lot. So, please, be easy on me.
Now, I am customizing a Bootstrap 4 ...
0
votes
0answers
25 views
How can I get the value of the field_percentage field?
I'm trying to create a custom template for the paragraph-progress-bar component.
The component I created has 2 fields: title (field_title) and percentage (field_percentage, integer field limited from ...
0
votes
1answer
34 views
How can I reference an entity field in a template file?
I am trying to theme the node add/edit form for a custom content type (for example, Album). I implemented hook_form_alter() in the theme.
function mytheme_form_alter(&$form, \Drupal\Core\Form\...
0
votes
1answer
27 views
Attempting to merge in an array of items into Twig classes
I have a Twig template where I'd like to merge in an array of items as classes. So far I have this code:
{% set classes = [
'media',
'media--type-' ~ media.bundle()|clean_class,
not media....
1
vote
1answer
36 views
Is it possible to dynamically select between two different template files for the same content type?
We are rolling out changes on a content type with a new theme and field structures for existing content.
Is it possible to dynamically select one of two template files for a content type?
For example, ...
-2
votes
0answers
50 views
How can I add async and defer to every JavaScript file? [closed]
I would like to know how we can add async and defer in each js script
What I have tried so for.
Using Advagg module in optimize js/css
In theme.libraries.yml but it break the functionality
Added ...
-2
votes
0answers
30 views
How to add an icon to a drupal text field
I am styling a drupal 8 website. I have created a new content type called course and trying to style its fields. I want to add an icon inline to a text field. Is there a way to do that using a plugin ...
0
votes
0answers
22 views
How selectively print the content of region.html.twig
I'm trying to modify the html of region.html.twig
I've used a hook to override the suggestion:
function my_theme_theme_suggestions_region_alter(array &$suggestions, array $variables) {
if($...
-2
votes
1answer
50 views
Is there any way not to include twig variable in .module file [closed]
Following Create custom twig templates for custom module, I see that variables should be set in the controller, but also defined in hook_theme(). To me, it's kind of redundant to have variables in ...
0
votes
1answer
9 views
Twig: Display media library reference user image at particular resolution with alt tag (on /user/1231 page)
On our user page (/user/12345) we want to change the profile image field to be a media library reference field instead. I've created for the user object a new field called field_profile_image that is ...
0
votes
2answers
49 views
How can I output the absolute URL as link text for internal links on link fields?
When using a link field without a link text and just with the URL, Drupal 8/9 outputs the relative path as the link text for internal links. How can I change that to either output the absolute URL or (...
0
votes
0answers
12 views
Suggested template in layout builder is not being picked up
I am using Layout Builder and I would like to tweak template file a bit.
I can see suggestions here:
But although I added file layout-twocol-section--node-npx-training-teaser2.html.twig in my theme ...
0
votes
1answer
15 views
When using a grouping field in an HTML list, is there a way to determine the group/loop number of the current content being rendered?
I want to be able to determine what group number is currently being processed to that I can treat the output of the first group differently than subsequent groups.
Unlike rows, I do not see a way to ...
-3
votes
0answers
32 views
Custom call throbber effect
Is there a way we can use throbber progress in custom call drupal 8. I am also using ajax loaded as well.
$("#button").on('click', function(){
jQuery.ajax({
url: base_url + "/...
1
vote
1answer
37 views
How to add “rel” attributes to all external links throughout the website?
I'm trying to add attributes for external links such as the rel="noopener noreferrer" for all the external links where target="_blank". I've tried using modules such as the ...
2
votes
1answer
79 views
Best practice: Twig logic versus Preprocess functions
I use Twig and Twig Tweak to do most of the processing. However, from time to time I need to rely on Preprocess functions to get the desired result.
This led me to a situation where now most of my ...
0
votes
1answer
16 views
How to print token in webform-confirmation.html.twig?
I would like to output a submitted value as a token on the confirmation page through the twig. The token works just fine when added into the message box of webform as:
[webform_submission:values:...
0
votes
1answer
55 views
How do I remove part of the HTML markup?
In my Drupal 8 template, I use {{ product.variations }} which produces the following HTML markup.
<div data-drupal-selector="edit-actions" class="form-actions js-form-wrapper form-...
0
votes
0answers
37 views
How to go back to the store in the product template?
In the product template, I can add the code below and display the store :
{{ product.stores }}
How to go up in the store to display the store fields.
For example, how to display the currency of the ...
1
vote
0answers
22 views
jquery.ui libraries-override > Incomplete library definition
I tried to remove the core jquery.ui theme.css by writing into mytheme.libraries.yml the following lines.
libraries-override:
core/jquery.ui:
css:
theme:
assets/vendor/jquery.ui/...
0
votes
1answer
37 views
How to display a message according to the country of the store?
On Drupal 8, I installed Drupal Commerce 2
I want to modify the TWIG file of the products to show "Made in France", if the store country is France and made in Belgium, if the store country ...
-2
votes
0answers
15 views
Twig syntax error page temporarily unavilable
I have Drupal Lightning profile on site
Drupal core 8.1.8.
I am using efrom to add data when I click the button to add data
error in recent log is
Twig\Error\SyntaxError: An exception has been thrown ...
1
vote
0answers
9 views
Add taxonomy term description to views-view-fields--taxonomy_banner.html.twig
using taxonomy term view to render my products in Drupal 8.9 with commerce 2 .
I am trying to add the term description under a banner .. but struggling to find what I need to add.
new to twig,and ...
0
votes
0answers
32 views
How to generate breadcrumb title for custom routes?
I'm using a custom theme for our Drupal 8 based website, for breadcrumbs I'm using the easy breadcrumbs module.
We have a custom module where the nodes are generated in a custom block dynamically.
...
0
votes
0answers
27 views
Access 'content' or 'node' variables inside View context
I have a view where there was a file type field. So I added it to the view and rewrote the result for it:
<a href="{{ field_documento }}">{{ title }}</a>
The above line results ...
3
votes
1answer
71 views
Page titles are wrapped in a span tag
On a site we are working on I was asked why the page titles are wrapped with a span tag. We are not using a base theme.
I checked everywhere I could think of, but came up short.
In page-title.html....
0
votes
0answers
24 views
Dynamic nid for drupal_field twig tweak function
I have a field_slides paragraph field on my home page, on drupal 9.1.3. It is for rendering a carousel.
I want to iterate over the elements of the paragraph field (eg the slides with title, ...
-1
votes
0answers
27 views
How do I set active trail or add active class for easy breadcrumbs?
I was using the easy breadcrumb module and found it very useful for Drupal 8, In easy breadcrumbs, I had few custom paths added. is there a way to add a active trail or active class with color for the ...
0
votes
0answers
14 views
Attached library not working in IE and old Edge
I've got a bit of an issue with IE11 and Old Edge 40.
I've got a custom module and I've attached a library that I want to run on every page with some CSS and javascript to the module. But it seems ...
0
votes
0answers
23 views
How do I add a font locally?
The following libraries example has the font being accessed from google and one local.
global:
js:
css:
theme:
styles/local.css: {attributes: { type: "text/css" }}
styles/...
0
votes
1answer
32 views
Why are the labels for two different form elements so different? Can I make them the same?
I created a webform that has one textfield and two radio button fields.
When displaying, the textfield label is themed correctly, but the radio button labels are not.
When I look at the tags and ...
-3
votes
1answer
82 views
How do I implement clipboard.js?
How to create a "Copy" button to copy a text in Drupal 8?
I downloaded the following library in the folder /libraries :
https://github.com/zenorocha/clipboard.js
Here is my ...
-1
votes
1answer
28 views
How to render a custom block in a twig file?
I created a custom block named "Alert Bar" in the "navigation" region and I want to render it in my header file.
My header file currently has code like this to render the blocks -
{...
0
votes
0answers
26 views
Drupal TWIG rendoring cleanup
I'm trying to get my head around how twig get rendered out. I just wrapped up working on my first Drupal site, which I really struggled with. So I spun up a local instance, to try somethings out. I ...
-2
votes
1answer
47 views
Why is my custom block template not being picked up?
I am working on a custom slider programmatically. I create a custom module (block_example) and make a block (BlockExample.php) and a twig file (blockexample.html.twig) and also a module file (...
-1
votes
0answers
23 views
How to add multiple languages for hreflang
I'm trying to add multiple hreflang's for my drupal site using the following:
$attachments['#attached']['html_head_link'][3] = array(
'0'=> array(
'rel' => 'alternate',
'hreflang' =>...
0
votes
0answers
29 views
Content translation not working on the front page
I have a translation problem on my site in drupal 9.1.3.
I have a content type for my homepage that contains two fields: field_slides which is an EntiyReferenceRevisionFieldItemList to a Paragraphs ...
0
votes
1answer
20 views
Render link in twig with 'entity:node/n' as uri in array
With the module "config pages" I've set some variables global to render in templates.
In mytheme.theme I've added a function:
function mytheme_preprocess(array &$variables, $hook)
{
$...
0
votes
0answers
17 views
Set background picture only within the text field, not the entire page
How should I make the background image appear within the text field (in the Basic page content type) but not the entire page?
I am using the Background Image Formatter module, running on Drupal 7 with ...
-1
votes
0answers
24 views
Parent store URL is not working
I am having problems since the last update of Drupal Commerce to version 2.23
At the top of my products page, there is an area with the parent store. This area is a link to the parent store.
Before ...
0
votes
1answer
43 views
How can I load a JavaScript file only when a page has an element whose class is “test”?
In my develop process, I meet a scenario: I only want to load a JavaScript file when a page has an element whose class is test, so what can I do? How to know a page whether has this element?
2
votes
0answers
54 views
How do I test for an empty Address webform element?
Using Drupal 9.1.3 : Webform 6.0.0
How to check for the null value of a Webform Address Composite element
{% if webform_token('[webform_submission:values:**ELEMENT_NAME**]', webform_submission, [], ...
1
vote
1answer
74 views
How to put the Bootswatch theme locally?
I am using this sub-theme
and I can't find any help.
bootstrap-barrio-installation
barrio-starter-kit
I am currently using Bootswatch Flatly in CDN mode. I want to put everything locally.
Here is ...
0
votes
1answer
26 views
Page title and body field of specific page
I have a page--front.html.twig file. I can't figure out how to show a specific node title and body summary on the frontpage with only using twig. I know I can create a view of something like that and ...
0
votes
1answer
19 views
I cannot sign into my drupal site. The login page just refreshes and there are no error messages
I cannot login into any account from the login page. I can get to the admin page by doing drush user-login but if I log out of admin and try logging in again, the login page just refreshes and I do ...
1
vote
1answer
49 views
how to create template suggestion for image like image--NODE-TYPE--VIEW-MODE
I'm trying to create a suggestion like image--NODE-TYPE--VIEW-MODE, but in mytheme_theme_suggestions_image_alter() $vars i haven't node related info
thanks for help