New answers tagged theming
0
votes
How do I hide the title on a specific node?
For Drupal 9, the title is a block. You can edit the block to exclude showing it on specific pages. If I recall, that's a core feature and not a plugin we're using. =)
1
vote
How can i preprocess variables php to js
To pass data from PHP to javascript, you need to attach the data to the render array of your block (or alternatively to some other render array via preprocess functions).
You can see an example here:
...
0
votes
How do I override the template file of a view so that it no longer displays links in my view, but only the plain text?
As a workaround, you can use the striptags filter of twig to strip the anchor tags.
https://twig.symfony.com/doc/3.x/filters/striptags.html
For example: {{ some_html|striptags('<a>') }}
0
votes
cant get file uri using field preprocess
In a template don't use a content variable to get references to objects. This is what the template is rendering. The structure depends on the field formatter and its configuration. Use it only if you ...
0
votes
How can I add CSS variables to the HTML head?
There is a module for COLOR variables on Drupal. It uses the core color module and has a UI if you need it. https://www.drupal.org/project/css_color_variables
2
votes
Twig adding extra spaces around output
These are probably not single space characters but other whitespace or HTML comment tags coming from the title field template. Try first to switch off any debug output, for example Twig debug. If this ...
0
votes
Twig adding extra spaces around output
The trim filter strips whitespace (or other characters) from the beginning and end of a string:
{{ ' I like Twig. '|trim }}
0
votes
How do you disable the CSS from a core module in Drupal 8 using libraries-override?
It was difficult to identify the correct library to exclude, using hook_css_alter made it easy for me to exclude a specific file.
function THEME_css_alter(&$css) {
$cssfile= "core/themes/...
0
votes
How do I print an exposed filter block in a template file?
I almost always use the twig_tweak module, there is 3 ways to render a block.
You can see the doc here Twig tweak Block render, you should probably use
drush ev "print_r(array_keys(\Drupal::...
2
votes
Accepted
add wrapper div to form element in content type
You can add theme suggestions to the form element and add the wrapper divs to the elements template. See How do I write a template file for a specific input field?
Or you can style the entire node ...
0
votes
Site errors out when trying to create a subtheme based on Classy
The root of problem: base theme changing after the theme has been installed.
How to change base theme:
Enable another theme;
Click on "Uninstall theme";
Change base theme;
Click on "...
0
votes
How to generate templates suggestion for media.html.twig for a specific field in a content type?
I found a workaround for this by using the view mode along with the content type. So the new code would be
/**
* Adds theme suggestions for media.html.twig
*/
function ...
0
votes
Determine which region a menu block is rendered in
The $variables["content"]["#attributes"] seem not to work anymore in all cases. The attribute tag has to be targeted to the specific content within the block.
Hence $variables[&...
0
votes
remove cache in hook_preprocess_node
In THEME_preprocess_node hook you can add the below code to disable the variable cache for particular content type.
if($variables['node']->getType() == 'content_type_machine_name') {
$...
0
votes
Accepted
How to show admin bar in custom theme?
Looking at toolbar.module, the toolbar is added to the page via hook_page_top() and the page_top area is output via html.html.twig.
The following snippet is taken from html.html.twig in core's stable9 ...
Top 50 recent answers are included
Related Tags
theming × 106767 × 2750
8 × 2509
views × 1441
nodes × 727
entities × 726
blocks × 618
forms × 536
javascript × 429
hooks × 404
media × 311
users × 306
6 × 296
navigation × 296
routes × 284
taxonomy-terms × 224
panels × 165
commerce × 158
webforms × 126
caching × 110
comments × 103
paragraphs × 102
search × 100
files × 95
9 × 95