Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [theming]

Use it for questions about rendering or modifying the HTML markup produced by a module/theme.

0
votes
0answers
4 views

Limit theme_webform_element() to One Form for Placing Description Above Field?

I have a very long webform, more than 200 fields, where the description needs to go above the input/textarea and below the label, instead of below the input/textarea. I am using webform 7.4.x and I ...
-1
votes
0answers
25 views

How to limit the product customization of a store type?

I have several types of store on my site and I want to modify the button "Add to cart" of all products associated with a type of store: I want to replace the text of the button "Add to cart" by "...
0
votes
0answers
20 views

Templates for nested paragraphs

What's the naming convention for twig templates for nested paragraphs? For example, if I have a content type that has a field field_content, and that field is a paragraph entity reference which ...
-1
votes
0answers
30 views

Add tracking code to <head> only for anonymous users. [on hold]

I would like to add a tracking code to the html.tpl.php file in Drupal 7 and I have tried the following code but it does not work. <?php if (!$logged_in): ?> <script>HERE</script> &...
-1
votes
0answers
24 views

Use Token in twig template

I would like to use the token [paragraph.field_zwischenseite_link] in my twig template to link my parent div. Unfortunately I get the error Message "The website encountered an unexpected error. ...
3
votes
1answer
67 views

How do I use 2 different taxonomy view modes on one node page?

On a node page I have a term reference field. This term contains 3 fields For the term I've created a few view modes: view_mode_first contains: field_1 view_mode_second contains: field_2, field_3 ...
0
votes
0answers
31 views

View Fields twig: How to get taxonomy terms for field?

I have a view fields hook that is listing content in twig. From those fields, I am able to retrieve other fields like text. {{ fields.field_teaser.content }} I am unable to get the taxonomy terms ...
0
votes
0answers
23 views

Unable to fetch paragraph's multi field values inside node twig

I have a content type as "worker". I have a Paragraph "test" and I am referencing "test" paragraph inside my content type "worker". This allows multiple values to be saved. How can I get the multiple ...
1
vote
0answers
19 views

When would tags be stripped out of a template? [on hold]

I've got a custom module in Drupal 8 that's putting out an XML feed. The structure of each item in the template that makes the feed looks like this: <item> <title><[[CDATA[{{ node....
-2
votes
1answer
17 views

Open Shortcut in new browser window

drupal 7.61 adminimal_menu I need to have two shortcuts on the shortcut bar open in a new browser window instead of the default same window without having to "right-click". Users are sometimes ...
-3
votes
0answers
22 views

Twig file only read in development mode [closed]

It appears as though the site will only use a new twig file when in development mode, but not in normal production mode. This is 8.6.3 multi-site set up. Things I have tried: clearing cache from ...
-3
votes
2answers
36 views

How to change the background color of blocks? [closed]

I just want to change the background color of a block on the “Sidebar First” region in Drupal 8. How can I do that?
0
votes
0answers
40 views

500 server error on cache flush [twig specifically]

I am getting a 500 error, The request timed out, The web server failed to respond within the specified time. This only happens if I flush all cache or flush twig cache, but not for css/js cache flush ...
1
vote
3answers
119 views
+50

Add class to form-tag in in views exposed form via template_preprocess_views_exposed_form()

I wonder how I can add a class to the form tag (of the _search_content_ view's) exposed form using template_preprocess_views_exposed_form() (or even better ...
0
votes
0answers
14 views

How to output a paragraph image field

I have a view that is pulling in multiple fields from a paragraph. (The idea here is that the view block will be output in a particular region.) I also have a custom paragraph.twig.html template that ...
0
votes
0answers
28 views

How do I render a node's link field in a page template?

I have a custom page template that's intended to display a couple of fields for a specific content type in an aside, along with the sidebar contents. My searching and reading seems to indicate that ...
1
vote
1answer
42 views

How to add pagination to programmatically rendered search result template

I am trying to implement the pagination in drupal 8 custom page. I have a custom array which I am rendering using theme, I need to add pagination for it. $internal_result = array_merge($...
0
votes
0answers
42 views

If logic in a view template overwrite

I have a view that has several decimal fields. I want to output the fields based on their value. Can I use a view template overwrite and twig if statement for that? Specifically Output the field ...
1
vote
3answers
61 views

How to get value from {{ item.content }} [duplicate]

I have a node named "reviews" and a custom field named "field_rating". I created a field template named field--node--field_rating--reviews.html.twig. I want inside the node to change the color with ...
1
vote
1answer
60 views

How to get the correct 'base hook' to override a template file in a custom module?

How can I find the 'base hook' to override a template file using a custom module? 'node' and 'user' are pretty straightforward, but others can be a little more elusive. Example code... MYMODULE....
2
votes
2answers
84 views

How to programmatically add custom markup to every displayed user name

Drupal 8.x I am currently using hook_preprocess_user(). I would like to alter the username to add some custom markup to every username. MYMODULE.module: function MYMODULE_preprocess_user(&$...
0
votes
1answer
52 views

_blank attribute doesn't get set

I'm trying to target on the Menu (Bootstrap) a _blank attribute. This is my code. It works on my local machine. if ($variables['url']->isExternal()) { $variables['options']['attributes'] = ['...
1
vote
2answers
68 views

How to customize the page /node/add? [on hold]

On Drupal 8, there is a page on /node/add. I want to customize this page by replacing the links with buttons, but I have not found a template to do that. I have also enabled the debug mode, but there ...
0
votes
0answers
13 views

How to use custom template in EntityListBuilder render method?

this is my render method from EntityListBuilder public function render() { $build['table'] = [ '#type' => 'table', '#header' => $this->buildHeader(), '#title' => $...
0
votes
0answers
22 views

How to know the type of store?

Drupal 8 and Drupal Commerce 2.10 I have several types of store on my site and I want to modify the button Add to cart of all the products associated with the store type online (online is the machine ...
0
votes
1answer
21 views

Get top 5 recent post by taxonomy term

I am new to Drupal and I have started overriding Twig files in Drupal 8. I have a requirement where I want other top 5 posts by taxonomy term. Suppose I have a category as JavaScript. And I am on the ...
0
votes
3answers
28 views

How to print an image in a paragraph that references a node with an image field

I have the following scenario: I have a paragraph called Timeslot that contains an entity reference field to a content type called Class. That content type has an image field called Class Badge. I ...
1
vote
1answer
112 views

How to display the status of the user?

I created a TWIG template for the "Teaser" view of the user account. I want to display a logo and change its color according to the status of the user : When the user is logged in <i class="user-...
1
vote
1answer
46 views

hook_theme_suggestions_HOOK vs. hook_theme_suggestions_HOOK_alter

Let's say some people are working on a contrib module (link) to provide some obvious template suggestions which are not covered by the default Twig Template naming conventions. View mode for fields, ...
0
votes
1answer
15 views

Author image not rendering in node twig file

I have created node for a Article content type. And I am trying to extract out author information in node--article.html.twig file. I am sucessfully able to fetch out Author name {{ author_name }}, ...
0
votes
1answer
34 views

Loop through entity in a template

I have a Site with a Twig Template. I have an multiple entity references which I want to loop trough and print out the name, description of each entity. In my template I'm using the following code to ...
-2
votes
0answers
10 views

How to recreate animated side menu? [closed]

I would like to recreate the hoverable animated side menu displayed in the gif. It comes from Dropbox Paper although it has cropped up on other sites that I have since lost track off. DB Paper is a ...
0
votes
0answers
22 views

How to get views header and footer in view block template

I have created view as block and in block twig template i can print view fields as content['#view'].field['field_machine_name'].value(row) HOw can i print text in textarea that i set as header and ...
0
votes
1answer
20 views

How to pre-populate paragraphs when creating a page

I have tried for some time to find out a way to populate a new page with a few paragraphs to save time on most of the pages (but which might change position or even get dropped for some pages) but so ...
0
votes
1answer
37 views

How to override node content in Twig

I have created no of nodes as content type as Article in my website(techladder.in). But I am not getting the right file where I can override the content of the file. For example, I need to display ...
0
votes
1answer
26 views

How to render a block in a template? [closed]

I installed the module "Shariff Social Media Buttons" for "Drupal 8" : https://www.drupal.org/project/shariff This module once installed, add a block in : /admin/structure/block I want to display ...
1
vote
0answers
38 views

What's the difference between adding a template and overriding a template, from a custom module?

I found a paragraph in the documentation about using template files in a custom module. This way can be even used to override a template like I did here. However, I am wondering if this is the ...
0
votes
1answer
50 views

Templates as content [on hold]

I currently have a project with the requirement to edit templates for content like content, i.e. we will have a template content type which will be used as template for another content type. I've ...
0
votes
0answers
26 views

utf8mb4_general_ci is not valid for character set utf8

I had changed my site from utf8 to utf8mb4 but when I run an update script for my theme, I get the following message: <h1>Additional uncaught exception thrown while handling exception.</h1&...
0
votes
0answers
9 views

How can I changed the commerce tax display label?

Is there any way or method to change the displayed label for Tax in the cart in Drupal 8 Commerce 2? The carts ends up looking like this because I have city, county, and state sales tax. But I need ...
0
votes
0answers
23 views

How to specify a condition if the store is not store_pro?

I created a custom module. If the owner of the current store does not have the marchand_premium role, the add to cart button is overwritten. I want to add another condition : If the store is not ...
0
votes
1answer
16 views

How to make one view with different taxonomy terms in different rows?

I want to make a view with 3 rows of lets say fruits, with 6 fruits max for each row. Spring, Summer and Autumn fruits. And I don't want them to be mixed in one array so I could style them in view-...
0
votes
1answer
34 views

How to customize a link with a custom module?

I installed the "Private Message" module on Drupal 8. There is a link to send a message that I want to transform into a Bootstrap button. How to customize a link on Drupal 8 ? Here is the HTML code ...
0
votes
1answer
30 views

How to add Google fonts locally

At the moment, I have this in my template.php drupal_add_css('https://fonts.googleapis.com/css?family=Short+Stack',array('type' => 'external')); I now have the .woff is the theme's folder. What's ...
1
vote
2answers
86 views

Unable to access Views fields in block Twig template

How Drupal 8 uses Twig, how different data is transferred from general template to specific templates? For view block I have created block template as per default template suggestions. In my new Twig ...
1
vote
0answers
24 views

How do I override the template of a region for a specific route?

I need to override a region only for a specific route. There doesn't seem to be a file-naming convention for this. If page--myroute.html.twig overrides the entire page at /myroute and region--...
1
vote
0answers
59 views

How to theme the user login page [closed]

I am new to Drupal 8 and trying to design the user login page as per my requirements but not being able to do it. My problem is: I want to restructure the elements of the user login form (/user/login)...
-1
votes
0answers
19 views

Add a custom variable in main menu template

I want to use a custom variable in my main menu template (menu--main.html.twig). After reading several posts, I don't see any solution. In a first try I tried to use a simply hook_preprocess_menu ...
0
votes
0answers
13 views

Pass node values to swift mailer module to create customize email template

I'm currently working on trying to build an email html template using swift mailer. My problem right now is how can I customize the template to fetch the values from the nodes and render them in the ...
-3
votes
0answers
18 views

How to sort row with custom PHP in PHP view custom field?

Using Drupal 7.61, views, and PHP filter I have a custom PHP field set up in views to display time zones, and I would like it to be sortable, but not sure what custom php code to put in there... ...