People who code: we want your input. Take the Survey

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
1
vote
1answer
758 views

Override user login form template

I'm trying to customize my user login page in my custom theme using the template file page--user--login.html.twig, but am having issues accessing the different form elements. All aspects of the form ...
0
votes
0answers
29 views

How to add the Group Role as body class in the page template

I like to add the Group Role of the currently logged in user to the body class of the page twig template. So this is not the same as the user roles the user account has. Currently using Drupal 9.0.3. ...
0
votes
0answers
31 views

Render content to multiple nodes from one input

I'm looking to create a dropdown of country selects each with two fields: field_item_title and field_button_link across multiple nodes. The content is populated by repeating nested paragraph fields. (...
1
vote
1answer
41 views

How to make node edit form meta panel accordions default to closed?

When editing a node the meta panel fieldset accordions default to being open if they contain data. I understand why this has been done, but I think it makes for a very noisy and potentially confusing ...
0
votes
2answers
618 views

Removing line breaks in Twig

My twig file is adding line breaks in the HTML which results in white spaces, as shown in this picture: In the browser inspector: When I remove the line breaks in the inspector, the white spaces ...
1
vote
1answer
73 views

Attaching Theme Library to Custom Module

I have a subtheme called bootstrap_subtheme. It has a library called global-styling. I created a custom module called telephone_alter. In telephone_alter.module, I have the following: function ...
0
votes
1answer
405 views

How to get the entity ID in a twig template

I have a custom entity, with the template my-custom-entity--my-entity.html.twig. How do I access the ID in the template? I can do this by implementing hook_preprocess_entity, but am wondering if the ...
0
votes
1answer
26 views

Check if the user has flagged content with any flag

It is possible with the following code to check if a content has been flagged by the current user with a certain flag: $flag = flag_get_flag('flag_name'); if ($flag && $flag->is_flagged($...
0
votes
1answer
70 views

Change placement of 'Read more' link in a teaser [closed]

I have a view where the content is displayed as teasers on the page. There is a 'Read more' link that is displayed above the body text for each teaser (refer to the screenshot below, circled in red), ...
0
votes
1answer
38 views

User edit form on custom page is resetting roles when user belongs to the “Administrator role”

I'm trying to display the user edit form on a custom page with limited fields. Submitting my form works well, but if I have the Administrator role, roles are reset. I don't understand why this is ...
0
votes
1answer
75 views

Generic field.html.twig template for a custom Entity

I have a custom Entity called custom_entity, along with a custom module which provides twig templates for my bundles and their fields. How can I define a generic/base field template for all fields ...
1
vote
1answer
225 views

Unknown drupal_view() function although Twig Tweak is installed

Acquia BLT won't let me commit some Twig. > tests:twig:lint:all Validating twig syntax for all custom modules and themes... Iterating over fileset files.twig... ERROR in ~/repos/agency/client-...
0
votes
0answers
15 views

When is [“und”] necessary in pre process hooks?

I've noticed in preprocess hooks that sometimes a field's value is found at - for example: $vars['field_caption'][0]['value'] and sometimes it's at $vars['field_caption']['und'][0]['value'] Which ...
-2
votes
2answers
42 views

How to load my module's css file after my theme's css file?

In my theme, I have css files loaded through mytheme.libraries.yml and mytheme.info.yml file. In my module I have added a css file like this function mymodule_page_attachments(array &$attachments)...
0
votes
0answers
39 views

Adding classes and aria labels to menu through template file to add accessibility, Drupal 7

How can I add classes and aria labels to main menu in template file Drupal 7 to enable accessibility in main menu dropdown. "ul" and "li" tags already have styling I need to add &...
0
votes
1answer
173 views

How to get pathInfo in twig? [duplicate]

I want get the pathInof in my template twig : How i can reach pathInfo please in my template ?
0
votes
1answer
73 views

Properly override template_preprocess_book_navigation function in Drupal 8 Book module

I'm trying to find what is the proper way to override the template_preprocess_book_navigation function from the Drupal 8's core Book module. I want to add only two lines (bolded), but don't know how ...
-3
votes
2answers
182 views

How can I style the Gutenberg module editor? [closed]

I'm trying to modify the CSS in the Gutenberg module to change the editor layout. Gutenberg uses SASS files to generate the CSS. I tried editing the CSS files directly, which I recognize I shouldn't ...
0
votes
1answer
46 views

Twig Template print field - if not node number

I can print an image field in my node template like this: {{ content.field_big_image }} But can I say "print this field but not if the node number is node/45" ?
0
votes
0answers
75 views

Drupal 8 custom theme, twig and template

I want to display all authenticaed users in a custom template with a custom twig file. All works fine, except that the twig file is not recognized or loaded. My module name is "ThemeLoader" ...
0
votes
1answer
72 views

How can I split the body field to insert content between the first and the second paragraph?

I have a node which shows content from the body field. I want to add a another paragraph or a block between between the first and the second paragraph, after the first </p> and before the second ...
0
votes
1answer
187 views

Form in custom module using Controller: The HTML tag form isn't present in Twig

I'm trying to render limited user edit form on custom page using Drupal Controller. In the routing.yml I defined _controller, I do not want to use _form. I want to display on the form e.g. only ...
-2
votes
1answer
60 views

how to apply a css code for a specific screen size

i am new in Drupal , in my case i have added a css code to implement it for just a specific width but in return i see it displayed for all screen size not the small or medium size it appears in all ...
-1
votes
1answer
46 views

Why does the login form become unusable after I removed all content from input.html.twig? [closed]

Actually I am stuck in a big problem . i am using input.html.twig file and i remove all the content from that and then when i see my default registration form and user login form which is prebuild in ...
0
votes
0answers
14 views

Adding full HTML field to Superfish/navigation

I'm looking to add a simple tag to a few letters in the navigation menu. It's super important that the person I'm working with has italics surrounding a few letters every time a certain work is ...
1
vote
1answer
111 views

Display summary of paragraph text field in twig [duplicate]

I have a paragraph type called News. In this paragraph type I have a text field (field_news_intro ) with a summary. How do I display the summary in a twig template? content.field_news_intro.summary ...
0
votes
0answers
38 views

Get upload date of a file

On my Drupal project, for a local cycling club, on the pages that show the different routes we'll be doing there is a link to a gpx file that contains the route details. Since routes change often ...
0
votes
0answers
22 views

background image with fallback

I am trying to add header images to my pages. I am currently getting the image in the form of a background using file_url(node.field_custom_image.entity.field_media_image.entity.fileuri) the problem ...
0
votes
0answers
38 views

Add class to button with specific class

I'm trying to add the class 'on-load-click' to any btn with the class 'webform-submit' <div class="form-actions"><button class="webform-submit button-primary btn btn-primary ...
0
votes
1answer
74 views

Block plugin's render array values ending up in $variables['content'] instead of $variables

I've got a bizarre issue where my the render array from my block plugin's build() method doesn't seem to be properly interpreted by the template. I've got the following setup. function my_module_theme(...
0
votes
1answer
46 views

Is it possible to call response()->setStatusCode() within hook_theme_suggestions_page_alter?

We set up a custom error page theme by creating a block with the error text and then used the following code within a hook_theme_suggestions_page_alter implementation to determine when to override the ...
0
votes
2answers
89 views

How to remove stylesheets only for anonymous users?

I am trying to remove all unnecessary/unused stylesheets for anonymous visitors to get better performance and a clean <head> section. This works fine by listing them inside mytheme.info.yml: ...
0
votes
0answers
22 views

How to add wrapper to article teaser content

I need to add a wrapper around the title, body, id, and created fields of the teaser below but am not familiar with how to implement this in a twig template. I need to have the image in a seperate ...
0
votes
0answers
130 views

How to use parent paragraph or field name in template_preprocess_file_link function?

We created custom theme suggestion for fields links using this code function THEME_theme_suggestions_file_link_alter(array &$suggestions, array $variables) { $route = \Drupal::request()->...
0
votes
0answers
12 views

getting custom field values

I set up a content type of example with custom fields. How can I get the field values to show in my twig template? I have tried {{ content.field_formattext‎ }} and that doesn't display anything.
0
votes
0answers
17 views

How do I add a class on a “checkboxes” element's option?

I have an exposed field with a "checkboxes" field, that I need to theme by adding (and removing) Drupal's default classes. I found close to nothing about how to do that, excepted this answer....
-2
votes
1answer
73 views

Show node summary (teaser) as tooltip/ Alt/ Title text on hover over nodes titles on front page with Views

I have a custom front page view showing nodes titles only without teasers. I want to have the teaser of each node show when hovering over any title. Something like: <a href="{{ url }}" ...
0
votes
1answer
57 views

How can I check in Twig if an advanced theme setting option is unchecked?

I've a list of advanced theme option(checkbox) to not display, such as search bar. I did many research about custom advanced theme setting, but all the samples are {% if remove_searchbar %}{% endif %}....
0
votes
0answers
24 views

Is there a way to pass custom data to a form template?

I have been tasked to customize a view, and I have been struggling with its exposed form, because I need to display some informations. Here is how it should look: These elements act as a checkbox, ...
1
vote
1answer
78 views

How can I show a date in Urdu?

I am working on printing dates in more than a language. With Drupal 7, I used the following code. <span class="arabic-date"> <?php $arrayurdudays = array('', '', '', '', '', '', ...
0
votes
0answers
26 views

How do I use a preprocess function for a custom template?

The content of this page is taken from a template file called hello-world.html.twig In my module file I have created the following hello.module file function hello_theme() { return array( '...
0
votes
1answer
68 views

In my Simplenews twig template how do I get the URL of the page I am emailing?

When a single test newsletter is sent, Drupal provides me with the expected URL as follows: {% set foo = url('<current>') %} <p class="link-to-page"> <a href="{{ foo|...
-1
votes
1answer
48 views

How to insert form into existing page template

Working in D8, I am trying to insert a form into an already created page/template file. I am using webforms, and on the webform submission page (that lists the submission details), I am trying to ...
0
votes
1answer
96 views

Theme a subscriber field in Simplenews issues

I need to address my subscribers in a more personal way. Thus I added fields for Mr./Mrs., firstname, lastname to the subscription block, and data gets collected nicely. However, I can't see how to ...
1
vote
1answer
134 views

Override page.html.twig with custom module template

I want to override the page.html.twig template from a custom module. I know how to create a suggestion, but I would like it to find the template file in my custom module. function ...
0
votes
1answer
130 views

Why is this if statement not working in twig?

It's a bidirectional D9 site where I removed dir=rtl from my theme's html.html.twig with an if statement and it's working fine. I did that to avoid an MS browsers bug ignoring position: sticky in css ...
0
votes
1answer
135 views

Hide block if no submenu in Twig

I'm creating a node--page.html.twig and I'm using twig_tweak to help render a block for my sidebar to display the sub-menus. Is there a way to hide it if the page doesn't have any submenus? Here's my ...
0
votes
1answer
199 views

How can I prevent one template from displaying cached values?

I have a site with Drupal 8.9 and Twig Tweak. I created 7 view blocks to set up a task list in stores. I want to display a task counter for my current user on my home page. The tasks checks : If the ...
0
votes
1answer
90 views

Twig template not rendering new field variable

I created a new field for a custom block type and have already exported necessary yml files and updated the yml for different view modes. However, when I make a reference to the new field using the ...
0
votes
0answers
40 views

Parent Theme overriding Subtheme on certain paths

I installed the Opgino installation for Drupal 8 and created a sub-theme for default theme that comes with Opigno. The subtheme works as it should, except on certain paths. Anything with a path of /...

1
4 5
6
7 8
210