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

Cannot get the sub-theme retrieve the CSS files from libraries

I have localized Bulma theme following the instructions which were as simple as creating a new directory called 'libraries' under main directory (httpdocs) and putting the sources files in it. No ...
0
votes
1answer
45 views

I can't override the node template

I have installed Barrio Bootstrap (8.x-4.33) and it worked so far. But I can't override a template for a specific node type. I copied the original template into my subtheme/template folder and named ...
0
votes
1answer
35 views

How to use hook_field_preprocess to add a prefix/suffix to an entity reference field for different view modes?

I'm trying to move some markup from twig templates to hook_preprocess_field(). I have an entity reference field (media image) that I want to add a prefix and suffix to. I added a prefix and suffix ...
-1
votes
1answer
26 views

How do I get the taxonomy term name?

I added a taxonomy field inside a view. I need to show the term name on the page in a grouped way, like this. taxonomy term1 name title1 content1 title2 content2 taxonomy term2 name title1 ...
0
votes
1answer
58 views

How do I get product variations in a preprocess function?

I'm trying to do something like this. function clientname_preprocess_commerce_product(&$variables) { $product = $variables['elements']['#commerce_product']; // Get the product variations and ...
0
votes
2answers
42 views

HTML is being printed in the output

The output from the below code is printing HTML. How can I make the "p" tags disappear? <p>answer 1</p> {% block paragraph %} <div {{ attributes.addClass(classes) }}> ...
0
votes
1answer
26 views

How can I write an if else statement in Twig based on commerce stock quantity?

Building a D8 Commerce site and trying to hide the price if the product is out of stock. I can access the stock value with this: {{ product.variation_field_stock_level.0 }} I've tried this: {% if ...
0
votes
0answers
24 views

Fatal error: “isEven” is an invalid render array key /web/core/lib/Drupal/Core/Render/Element.php

we have this code in template.theme but when we go to view the web, the page show a error as this: "isEven" is an invalid render array key /web/core/lib/Drupal/Core/Render/Element.php . I ...
0
votes
0answers
22 views

Conditional display mode for entity reference field

i am having a paragraph with 2 fields : Slider : field_gallery_slider / Booléen Images : field_gallery_image / Référence à une entité media How could i change the media display mode if the ...
1
vote
0answers
32 views

Render Twig Template instead of standard node fields [closed]

Right now my custom module creates a new content type. When an admin creates a node of that content type and save it they see the standard form elements displayed. However the custom module creates a ...
0
votes
0answers
36 views

Render a field of a “node_view” array in a block template file

I want to render a field_address field (text field) in a block template file. The node is loaded in a preprocess function. I know I can print the field value with {{ front_nodeObj.field_address.entity....
0
votes
0answers
32 views

Referencing images in files directory from twig template

In a newly installed Drupal 9 site, I have images in the sites/default/files/ directory which I am trying to use in my custom theme. In my theme, I'm implementing a custom entity-print--node--deal....
0
votes
1answer
34 views

phpwkhtmltopdf engine pdf printing configuration issues

The screenshot below shows my Entity Print configurations for created styled PDFs from node content. As shown in the screenshot I am using the phpwkhtmltopdf engine and the mikehaertl/phpwkhtmltopdf ...
0
votes
0answers
46 views

Entity Print PDF stying issues

How can I apply CSS styling to a PDF generated from node content? Using the Entity Print module I am able to create PDFs from my node content. My problem is the PDF output do not reflect the styling I ...
0
votes
1answer
38 views

Displaying a single result out of three results

I have a view block that is set up to produce three product titles sorted from a taxonomy term (flowers). I have a view whose machine name is latest_products. In a preprocess function I use the ...
0
votes
0answers
21 views

Admin interface styles sometimes missing; frontend CSS loaded

Using administration pages on an old Drupal 7 installation, the "normal" admin CSS styles are sometimes gone and the page appears with the frontend layout. After reloading the page, the ...
1
vote
2answers
42 views

How can I change the user login tabs labels?

I am pretty new to Drupal and wonder if there's any possibility to change the text of the user login / create an account and reset tab? I'd like to rename them to something like "sign in", &...
0
votes
1answer
21 views

What does the checkbox “link to content” do?

I am creating some custom content but have not got round to creating the views yet. When looking at the layout tab I see this What content does this refers to? All my Plain text fields have this ...
0
votes
1answer
46 views

How to update the TWIG flag conditions?

I have this code in my sub theme : bootstrap_subtheme_front_office_old.theme <?php /** * Implements hook_preprocess_HOOK() for user.html.twig. */ function ...
-3
votes
1answer
46 views

Unable to display message when account is flagged

I have this code in my sub theme : bootstrap_subtheme_front_office_old.theme <?php /** * Implements hook_preprocess_HOOK() for user.html.twig. */ function ...
0
votes
1answer
60 views

Autocomplete field where title is replaced with NID

I'm using Drupal 7 and I have made autocomplete function to be called on a field. File my_module.module: <?php function my_module_menu() { $items = array(); $items['/...
-4
votes
1answer
56 views

How to limit to certain page with TWIG?

I want this code to appear only when I visit one of the three paths below. How to do this in TWIG ? /product/add/produit or /product/*/edit or /product/*/duplicate The condition below does not work....
0
votes
1answer
31 views

How can I alter node markup from a custom module (not theme)? [duplicate]

In a custom D8 module (not a theme or sub-theme) what is the best way to alter all nodes of a specific content type by prepending them with simple markup? I'm trying this approach with no success ... ...
0
votes
0answers
17 views

Theme Node Add Form for content type created in custom module

I have built a module in D9 that creates a content type. Now I am trying to theme the node/add form. my_module.module <?php /** * Implements hook_theme(). */ function my_module_theme() { return ...
1
vote
0answers
45 views

How to display the rendered entity of a store in the purchase funnel?

I created a link that displays the "Terms and Conditions" of the store to which the shopping cart relates in a modal window. This link a page in a modal window. I want to replace the page ...
0
votes
1answer
29 views

How can I inject relevant/filtered ads every 5th result in a view?

I have a view that displays filtered results of Business Offers and Events as "cards". Now my boss wants to inject relevant custom ads into the results based on the user selected filters (...
0
votes
1answer
39 views

Get media image url in views-view-unformatted template

I'm using drupal 8, in my template I created a file named views-view-unformatted--block-12.html.twig and this is it's content: <div class="row list"> {% for row in rows %} {% set ...
1
vote
1answer
81 views

Twig find if a css class exists in a tag

Is there a way to find out if a css class exists in a specific tag through twig? For example: <body class="new-class"> Then I'm able to do a conditional statement in twig based if new-...
0
votes
1answer
47 views

How do you programmatically get the current user's status?

I'm trying to get the currently logged-in user's status (active or blocked) in template_preprocess_user. I tried the following with no luck. function MYTHEME_preprocess_user(&$variables) { $user ...
0
votes
1answer
60 views

Is there a way to change how a form button looks?

I know how to add a class to a form element and how to add a form submission button, but there are classes that are automatically added to these buttons in my Drupal 8 install. The form I am editing ...
2
votes
0answers
49 views

How do you reliably create a GraphQL/Twig theme as a subtheme?

Our theme is built with GraphQL Twig and it's working great. We need to build a subtheme for a different website based on this theme. We're not really having a problem overriding simple Atoms ...
0
votes
0answers
23 views

How do you create skins for the views slideshow?

Supposedly, in Drupal 8 you can create custom styles for your slideshow (Views Slideshow), which the README refer to as "skins". Normally I'd use a css, but the module annoyingly includes a ...
0
votes
1answer
35 views

Load Bootstrap CDN only if not is loaded before from another project

I want to load Bootstrap CDN but only if is not loaded before. How can I do this? Today I'm loading on Libraries.yml like this: And it works. But the problem is: in some cases the Drupal site already ...
0
votes
1answer
24 views

How do you make a Image View of a specific page?

I have a problem. The thing is that I know that you can have a [Content Type] with an image [Field], and then you can create a [View] to display the image [Field] in each of the pages that are of the ...
1
vote
1answer
19 views

How can I link the file name to the file?

I created a content type with a "file" field type. This to upload a pdf file. Now I want to create a link to open that specific file, in my twig. If I do this : <div>{{content....
-1
votes
1answer
17 views

How to display default drupal search block in twig template

In twig_tweak module before version 2 (for Drupal 8) I could place the following code in my page twig template and it would work: {{ drupal_block('exposedformsearch_contentpage_1') }} This would ...
1
vote
1answer
51 views

Adding attributes to a link to an uploaded file

I have been asked to add target="_blank" to the links that are produced when a user uploads a file on a Drupal 8 site. The field type is "File". Multiple uploads are allowed. Twig ...
-1
votes
1answer
48 views

How to use a Twig variable as View name in drupal_view() Twig Tweaks function? [duplicate]

This works: {{ drupal_view('nursing_resource_blog_teasers', 'block_1') } But this doesn't: {% set view_name = "nursing_resource_blog_teasers" %} {{ drupal_view(view_name , 'block_1') } It ...
0
votes
2answers
35 views

creating a custom report page with a table

Drupal 8.9.6, I'm trying to create a custom module admin report page. I have a custom sub theme of seven called wd_admin. I made a page controller that generates a table as markup, but want to use a ...
2
votes
1answer
73 views

Why can html.twig files be placed outside the templates folder?

In Drupal theme folder structure, there is written: Templates provide HTML markup and some presentation logic. Contrary to Drupal 7, in Drupal 8 template files (*.html.twig files) must be stored in ...
1
vote
1answer
73 views

How to render a field of a taxonomy term inside a view template?

I'm trying to display an image as a banner above the items of a view (which creates a block). The image is a field associated to a taxonomy term and the view is used to display all items which have ...
1
vote
1answer
48 views

How to move views pager to different region as a block?

I created a page view and results are showing up in main page content block. Now i need to move the pager attached with view to different region. I am not sure how to achieve this. Please suggest any ...
2
votes
2answers
152 views

How can I stop the full HTML editor from deleting my <p> paragraph?

https://drupal.slack.com/archives/C1BB308HH/p1602318464360700 Link to slack question in #support JSFiddle of the offending html: https://jsfiddle.net/tyeth/xr4ohast/ Demo Video showing the paragraph ...
0
votes
0answers
34 views

How to add attributes (classes, id, …) to preprocessed text of field? [duplicate]

I'm working on a theme for Drupal 9 where I'm rendering a node's field, which consists of multiple "raw" HTML elements (without any attributes). The item.content variable inside my field ...
1
vote
1answer
53 views

How do the variables in .twig files work?

I am using a theme based off awesome zymphonies theme. I'm trying to use the site_logo variable from page.html.twig, but it doesn't have access to it, instead I have to use the page.header region, ...
1
vote
2answers
77 views

What could cause a View template to ouput wrong row index?

Context I have a weird issue on my live environment that I have never seen on my local environment. Cache bins are disabled on my local environment and enabled on live server. When clearing all caches ...
0
votes
0answers
19 views

Modify entity field from preprocess hook

I can't get how to modify an entity twig variable from a preprocess hook. It is easy enough to add variables to your twig templates but I don't get how can modify an entity predefined variable. In my ...
1
vote
2answers
60 views

Create a custom fieldset template

Normal scenario In a custom form (created using FAPI) I have a fieldset definition: $company_field_set = [ '#type' => 'fieldset', ]; If I would like to customize the fieldset template, I ...
0
votes
1answer
10 views

Combine multivalue field rows with copy of same multvalue field

Having a list of pdfs using pdfpreview for image-preview I want to add an additional formatted text-field to this ouput. That's why I've created a copy of this field with a different formatter (e.g. ...
0
votes
0answers
45 views

Alter core and add wrapper twig template

Our site has multiple block twig template in our theme (20+). They are simple. When the block is in the layout builder we need to add additional things (admin label, classes, etc), because nothing ...