Questions tagged [theming]
Use it for questions about rendering or modifying the HTML markup produced by a module/theme.
10,703
questions
0
votes
1
answer
783
views
Use form_alter to change description under reset password field for user_pass form
I'd like to change the text below the reset password field. I took a look at this answer, and it talks about changing the button, but I need a bit of help to change the text.
Here is the debug output ...
0
votes
1
answer
671
views
Manage Display Field Label not changing: inline does not work
I have the same problem as question 212176 and discovered it has to do with CSS.
I have 2 (local) sites both with module ds enabled. I configured in both a field where I want the label and the value ...
1
vote
1
answer
502
views
Blog monthly archive block - list of posts grouped by year then month
See the implementation on this guy's blog: http://deglos.com/blog
YEAR
-- Month
-- Month
YEAR
-- Month
-- Month
Anyone know how this was accomplished?
1
vote
1
answer
644
views
Adding two contextual filters (Content : nid)
I want to display two type of contents : News and Events.
So I added them in the filters criteria. This works great.
Now I want them to be further filtered on the basis of the category the News and ...
2
votes
1
answer
280
views
How do you override a module's template from another module?
I'm trying to override an email template of the webform module. The project is headless so we don't have a custom theme, and we'd like to stick with the Adminimal contrib theme. However, we do have a ...
0
votes
1
answer
515
views
How to inject code into node body after x paragraph
Trying to figure out if there is a way to inject code after the first or second paragraph on a node.
More specifically I am trying to inject an Adsense ad.
So far I haven't been able to find a ...
0
votes
2
answers
548
views
Is there a reliable way to show Drupal messages from JavaScript?
I need to show status messages (the kind typically shown by drupal_set_message()) in my module's JavaScript code. How can I do this reliably, such that the theme and placement of the messages remains ...
0
votes
1
answer
398
views
Override Profile2 with account fields and values
I have created a new Profile Type with Profile2 module. Now I want to override it, importing three existing fields from my original Account (First Name, Last Name, Email) with their own values (that ...
1
vote
1
answer
632
views
Display Entity Reference field twice, with different display modes
I have a content type (Type A) that has an Entity Reference field to another content type (Type B).
Type B has 3 fields and 2 display modes. Display A shows two of the fields, Display B shows the ...
0
votes
3
answers
3k
views
Drupal 8 theme showing Uncaught TypeError: $(…).find(…).once is not a function in console
New to Drupal 8.
I've created a demo theme. The .libraries.yml file is below:
global-styling-and-scripts:
version: VERSION
css:
base:
assets/css/font-awesome.css: {}
assets/css/bootstrap....
0
votes
1
answer
697
views
Print rendered field in views-view.html.twig
I try to render a custom node field in a views-view.html.twig and it works, the only thing is that i get the machine name and not the formatted name. Please can somebody describe me what i am doing ...
0
votes
2
answers
650
views
Add CSS classes to theme function
I'm implementing hook_theme() in a custom module.
function monitor_chart_theme() {
return array(
'chart_monitor' => array(
'template' => 'monitor_chart',
'variables' => ...
1
vote
2
answers
3k
views
Rendering a nested Paragraph's field using Twig
We are using the Drupal 8 Paragraphs module and are have a Paragraph which contains a Paragraph type field, called "Steps" (machine name fs_steps), allowing editors to add a number of "Step" ...
1
vote
1
answer
1k
views
Can't seem to format date in twig from UTC to User's locale
I am trying to format the date field from an event content type that I've created so that I can pass the date into an event exporter that creates events in calendars such as Google, Apply, Yahoo, and ...
0
votes
1
answer
511
views
Have Views based Taxonomy Term page use term description for title
I am using a view to replace the standard Taxonomy Term page (turned on the standard one in Drupal 8.x). I want the Title of the page to be changed from the Name of the term to the Description of the ...
0
votes
1
answer
490
views
Use page.html.twig template variable in another twig template
How do I call a page.html.twig template variable from the book-tree.html.twig template.
Using kint, I have found the variable, nid as in the screenshot below:
The 'nid' is highlighted, but it is the ...
0
votes
1
answer
401
views
Using Twig in global custom text to check for a specific content type
I am filtering for two content types to display in a view: Artwork Page and Cover Page. I want to change the HTML markup for Cover Page.
I have researched and tried many field names for Content Type, ...
0
votes
2
answers
58
views
Can't get real field value from paragraph
I need to get value from exact paragraph type in paragraph reference field in node, so I can use it in Twig.
Here's my current code:
function my_theme_preprocess_field(array &$variables, $hook) {
...
1
vote
1
answer
672
views
Access to core comment preprocess variables in a custom comment layout twig template?
In Drupal 8 I have a custom comment type and when I use the default core comment.html.twig to render the comments then variables like 'new_indicator_timestamp' and 'parent' get rendered as expected. ...
0
votes
1
answer
407
views
Custom user_register_form for Auto Assign Role registration pages
I'm using a function[a] to get custom templates to work for all pages, including role registration pages set by Auto Assign Role. By setting the role registration path to user/register/<rolename>...
0
votes
1
answer
2k
views
Using webform-form-[nid].tpl.php to change default template
On drupal 7, using webform 7.x-4.11, I am trying to modify the template of a specific webform.
So, in /web/themes/bartik/templates (I am using bartik theme) I created a file named webform-form-23.tpl....
2
votes
1
answer
2k
views
How do I add a script just above the closing body tag?
How do I add a script on Drupal 8 site/app just above closing body tag?
Vendor provided some JS in the following form:
<script>
... code
</script>
Asked me to place immediately ...
1
vote
1
answer
397
views
Using theme_preprocess_node i'm trying to add a class to all images on the page
My code below is not working and i'm not sure why. I've tried a few variants.
according to the KPR variables output, the image I'm trying to access is here.
$variables['field_about_image'][0]
i ...
1
vote
1
answer
362
views
JCarousel Views - Multiple Rows
My problem is related to Drupal and the use of the JCarousel module for my views. I'm having a few problems with this, namely in getting a jcarousel like view style but with 2 rows instead of one. ...
-3
votes
2
answers
60
views
Update entityManager()->getViewBuilder from 5 year old site?
I have a Drupal 8 module which hasn't been updated for 5 years.
I m trying to update to current version of Drupal.
The error I get is
Error: Call to undefined method Drupal::entityManager()
The code ...
1
vote
2
answers
529
views
Passing variables from hook_mail to cutom twig template
Custom twig template into hook_mail()
$body_content = array(
'#theme' => 'mail_body_content',
'#node' => $node,
);
I would like to access to node Entity and display value into the twig
...
0
votes
1
answer
667
views
How do I load CSS files to a custom theme?
I understand this question has been asked many times. However, I still can't figure out why the CSS files of my custom Drupal 8 theme are not loading.
Edited (more info): The CSS files are not being ...
0
votes
1
answer
667
views
How can I loop through all article content types and get the content of each
I created a new article content and am overriding that by creating a template for it (ie: node--4.html.twig).
Then inside this template, I want to loop through all nodes that belong to article ...
0
votes
1
answer
538
views
Defaut image value not showing up
In my article content type, I've added a header image (field_header_image) field which I placed a default image into it so that all articles would have a default image used if one wasn't needed. ...
0
votes
1
answer
25
views
Use a different template file for front end and submission view
I have defined a custom template file referenced via #theme for my custom webform element.
public function getInfo() {
$class = get_class($this);
return [
'#input' => TRUE,
'#process' =&...
3
votes
2
answers
577
views
How to remove markup from file field
I have added a file field in views and when displaying it has some markup like this
<div id="file-218" class="file file-image file-image-jpeg
contextual-links-region">
<a href="#">
...
0
votes
1
answer
790
views
Add target blank to an image link
How do I add target='blank' to a href in a Drupal 8 custom module? Below I have the image being wrapped by the uri. I don't know how to add target='blank'
$element[$delta] = array(
'#theme' ...
3
votes
1
answer
1k
views
Site errors out when trying to create a subtheme based on Classy
I'm creating a custom theme in Drupal 9 and am trying to use classy as my subtheme but get the following error:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Theme\...
2
votes
2
answers
460
views
Add css-class based on productpages' top level taxonomy term
So I have a website (created with drupal 7) where each product is linked to a taxonomyterms. This was done so that all products can easily be divided into several different categories.
So I have a ...
0
votes
0
answers
38
views
Programmatically render block content render array with wrappers [duplicate]
I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this:
$block = \Drupal::entityTypeManager()->getStorage('block_content')
->load($bid);
$...
1
vote
1
answer
424
views
hiding taxonomy terms on term page
I'm struggling theming the taxonomy-term page and since i'm not really getting anywhere, i now embedded two blocks (created with views) in my taxonomy-term.tpl.php. Now, that views is showing ...
1
vote
1
answer
22
views
Image from field not properly displayed in teaser
On Drupal 10 with Olivero theme, I set image in teaser to be displayed with original size.
I also made sure the image field display is enabled in teaser view.
Still, the image is shown on the left of ...
2
votes
3
answers
2k
views
How to display a block if a Boolean on/off checkbox is checked?
I will eventually install Panels to accomplish this. But I can't at this time. I want to allow an editor to display a right sidebar menu on any page when they want by checking a Single on/off checkbox ...
0
votes
1
answer
45
views
How to make it so theme function isn't used when editing a node with layout builder
I have the following two functions in my .theme file that I'm using to gleam various bits of information from both the path alias and internal URL of the page being viewed. They are:
function ...
3
votes
2
answers
488
views
Change icon class in "Add to cart" button
I am using Drupal 7, Ubercart, and Bootstrap. The default Add to cart button looks like this:
<button id="edit-submit-270" class="node-add-to-cart btn btn-success form-submit" value="Add to cart" ...
1
vote
1
answer
46
views
How can I render comment pager on the top and the bottom of the comments portion of the page
When comments are numerous on a node and you have a high comments per page setting, you have to scroll a lot to get to the pager.
My users have requested pager at top as well as bottom of the comments ...
0
votes
2
answers
506
views
How to programmatically add a link to an image field in a view
I have a view with an image field and other fields, and I need to link the rendered image, not the content which is one of the configuration choice, but on another computed filtered view.
I think that ...
0
votes
2
answers
400
views
recent content block with thumbnail?
I want to theme the Recent Content block with associated thumbnail of each node. After researching for a long time I found the function node_get_recent(). This function selects data from table 'node', ...
0
votes
1
answer
1k
views
Adding a variable to a menu twig template
Im trying to use bootstrap for an accordion menu. My issue is that I need unique ID's for each accordion item. I found some similar topics here: Add Unique ID to Menu Item and here: How to add a ...
2
votes
1
answer
395
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 ...
4
votes
5
answers
10k
views
How to get the label values for list fields in Twig?
I'm trying to fetch the label of the list and display it on the twig template.
Using node.field_list.value outputs the key value. I tried using node.field_list.label but it returns empty. I tried ...
0
votes
2
answers
736
views
How do I create a sticky navigation bar in Open Social?
I'm using D8 and working on new theme in Open Social witch uses bootstrap/sass. In my theme I want the navigation bar (in the header region) to be sticky at the top of the screen.
I've made some ...
0
votes
1
answer
408
views
How to theming on webform field element in single twig file (for example webform--contact-us.twig.html?
I have tried a lot to get form element in webform twig file. But variables are not coming.For example : when I'm using {{ element.elements.name }} in webform--contact-us.twig.html , nothing I'm ...
1
vote
1
answer
1k
views
Print image with alt text
In the node template, I print an image gallery. I need to add the alt text.
<div class="field--name-field_gallery">
{{ content.field_gallery }}
{{ content.field_gallery.alt_field }}
</...
0
votes
2
answers
492
views
Disable select drop-downs, display names only
I am looking for a way to remove the select drop-downs from the datepicker popup and display only months (and the year). As for the appearance, it can be altered in datepicker.1.7.css.
How do I ...