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
3
votes
3answers
1k views

Truncating text instead of wrapping in a view

I have a view that displays an image, title, star rating and user name of a custom content-type I have created in a grid. When I have a very long title it messes up the layout of the view and makes ...
0
votes
1answer
438 views

How to access a parent paragraph twig file from a child node twig file?

In my bootstrap theme, I am trying to make the id of the paragraph the same as an attribute for each of the child nodes, so an accordion will work properly. I have tried looking at doing it through ...
0
votes
1answer
723 views

Why aren't CSS files served? There is nothing in sites/default/files/css

In my Drupal 8 installation profile, I install a theme and a lot of configuration for it. I'm using Features to install blocks/settings/views for it, but when I enable the feature Drupal stops ...
1
vote
3answers
1k 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 ...
-1
votes
0answers
27 views

Current page link is not adding in my custom theme full pager links

I have created a view page showing products with full pager and full pager links are showing currently but current page link is not been added in the pagination links and because of this pagination ...
2
votes
3answers
2k views

How do I check the value of a field if its empty?

Is there a way to check, in a preprocess function, if the value of a field is empty? I'm getting the following error. Call to a member function isEmpty() function ...
0
votes
1answer
65 views

jQuery dependency on a custom theme is not adding jQuery?

I know that this question has been asked previously many times but any of the solutions are not working in my case so please, I request if anyone can help me with this situation please provide me ...
0
votes
1answer
525 views

How can I reorder active menu items programmatically?

I have an 'audience' menu which has 4 links. When a user visits one of these links, it becomes active, and I want to push it to the front of the menu item list. Outcomes would like like; Pitchers | ...
2
votes
1answer
406 views

Adding Price Attributes

I am searching how to add price values to existing product attributes in Drupal Commerce 2.X For Example: T-shirt price = $10.00 A product variation/color = Red = +$2.00 A product variation/size = ...
0
votes
1answer
556 views

How to use 'use-ajax' class with pages created by controller?

I'm trying to use 'use-ajax' class to load a page inside a modal box. My Page is dynamically created using node id pass on my page controller My link looks like this Any idea on how can I achieve ...
2
votes
2answers
448 views

Theme developer module crashes the whole site when enabled, how to fix?

I'm working on a clean Drupal 7.x installation, downloaded Theme developer and its dependent module simplehtmldom API( another required module for Theme developer) using drush. I found out that ...
-4
votes
1answer
436 views

How to link css to a custom theme to load on specific pages

how to link my custom CSS to a drupal custom theme. and how I can link a CSS file only for a single or some specific pages. like I have a CSS library which I need to load on the gallery page only. I ...
0
votes
0answers
7 views

How to get the URL of remote video inserted by media field in block or paragraph twig?

How to get the URL of remote video inserted by media field in block or paragraph twig? I am using the paragraphs module to create video galleries from youtube videos. When I use {{ content....
1
vote
1answer
4k views

Render entity reference field with link in node template

I have a content type with an entity reference field to select a user. Now I would like to render this field in the node template so that the field links to the user profile. I set the format of the ...
5
votes
4answers
10k views

Get total row count in views-view-fields.html.twig

How can I get the total rows number in views-view-fields.html.twig template file in Drupal 8? In Drupal 7, I can get it by the following code. $view = views_get_current_view(); $view->total_rows; ...
0
votes
0answers
24 views

Is it possible to use only one module for multiple Site Studio (Cohesion) elements?

I'm creating custom elements to use within Acquia Site Studio/Cohesion (following this), but one majorly inconvenient thing is that you have to create a whole new module for each element. I'm trying ...
0
votes
1answer
28 views

How can I add CSS variables to the HTML head?

For my site I want to be able to set custom css variables to the sites head. I don't want to add css files just inline css code. In the end I want users to be able to set colors using a color picker. ...
1
vote
2answers
1k views

How to add block template suggestions?

I want to be able to create a block or place a block into a region and theme it according to the selected view mode from Panels. I have noticed a discrepancy between Custom Block and Entity Block ...
0
votes
0answers
21 views

Get the first letter of each word in a string in twig [closed]

is there simple we can get Get the first letter of each word in a string I google it and found an answer for PHP not for twig. PHP answer link that what I want in twig Click here {% set string = "...
46
votes
13answers
79k views

How to get the valid URL of a Link field from within a Twig template?

I have a Link field named field_my_link (machine name). Within a Twig template I can get the link's URL value with this: {{ node.field_my_link.uri }} If inside the Link's URL there is an external ...
0
votes
1answer
1k 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
3answers
278 views

How to alter file upload description text

I'm trying to customize text for a file upload widget in Drupal 8. Here is a screenshot of the widget: I just want to display the first 15 MB which I added as file field description text in the ...
0
votes
3answers
342 views

Remove separator from breadcrumb

How can I remove the < from the breadcrumb I tried implode('<', $value['data']) but no luck function bootstrap_fit_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb'];...
1
vote
1answer
406 views

How to print the raw value of a custom user field in comments

I want to print a custom user field of the commenters. It is an Link field (https://www.drupal.org/project/link). Some users have that field completed and other not. I've read a lot of posts related ...
0
votes
1answer
506 views

Alter title link in taxonomy view mode

Under /admin/structure/taxonomy/my_vocabulary/display/entity I've got a view mode "entity". For this view mode, I would like to alter the way the link in the title field is built (the title is ...
1
vote
1answer
401 views

How to remove custom block parent div's?

I have created custom block in my custom module. I have created block template file into module templates folder. Custom block content coming successfully as per given in block__MODULENAME__dummmy_xyz....
47
votes
17answers
95k views

Getting the image URL from a field_image on a node

So I have this Node: object(Drupal\node\Entity\Node)[1862] protected 'values' => array (size=17) 'vid' => array (size=1) 'x-default' => string '7' (length=1) ...
1
vote
1answer
3k views

Add a span/class to a field

I've found a way to add a style to a region. The link is /admin/structure/ds/styles. I've found a way to specify a style for my Title. We can choose the "class" attribute of title property. Howe ...
1
vote
1answer
415 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 ...
1
vote
1answer
24 views

How to add template suggestions for form elements of a certain form ID?

I'm looking to edit some Twig templates for certain form elements, but I need template suggestions only for certain form IDs. How do I go about that? I currently have the following functions in my ....
1
vote
1answer
368 views

How to wrap / manipulate element outputs on a form's checkboxes html?

I have the following form that contains a big list of checkboxes. The first checkbox is the parent of the children below it. In my case it is called "Africa" and the ones below it are "Africa-child" ...
0
votes
1answer
366 views

Custom sort to preserve order of referenced nodes

I have a node type that references other nodes. When viewing node of Content Type A, I have set up a view that displays all references to nodes of Content Type B on a gmap. This is the code from a ...
0
votes
2answers
609 views

What instantiates a CacheBackendInterface?

I am working on upgrading a module and there is a use statement use Drupal\Core\Cache\CacheBackendInterface; What is the point of using an interface like that? Interfaces dont have actual code and ...
0
votes
0answers
9 views

field widget form element not updating #attributes via #ajax callback

I am trying to do a simple update to a form element in my field widget, I have a start and a end dates in the field widget and I need the start date to be the min date of the end date, so I call an ...
-2
votes
0answers
12 views

How do I theme multiple uploaded files?

I want to create a file field where I can upload multiple files but I want to change design of the uploaded file. I want to remove checkbox, I want to display only count of the file instead of name of ...
0
votes
0answers
9 views

Show field conditionally + display each form part in div

I've followed the tutorial in order to create field conditionnaly, but the field is always shown. This is possibly due to the way I'm calling my form ? And if I do as I did in my template, how can I ...
0
votes
1answer
18 views

Adding Count Up module to custom front page

My end goal is to put several Count Up numbers on my custom front page. But I'm having trouble getting it implemented. First, I installed the Count Up library (https://github.com/inorganik/CountUp.js) ...
0
votes
1answer
32 views

How to add custom attributes to description meta tag?

I need to add 'class' and 'data-type' attributes to meta tag containing description attribute. I was able to locate the core Metatag module, however I'm unable to find any documentation on how to ...
0
votes
1answer
642 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
1answer
396 views

How to create a responsive views block in bootstrap?

I created a content type with one field collection field using Field collection module which accepts up to 4 values. Field Collection: Field collection field has 3 fields (text1(40 char), text2(255 ...
-1
votes
1answer
19 views

How to create a template for the product variation?

I have enabled debugging in the drupal service file. My product type display the rendered entity of the RSS view in the variation field. When I inspect a product page no model for the variatin is ...
0
votes
1answer
383 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
0answers
22 views

Using TB Megamenu, how to close one submenu when I open another submenu?

I'm building a couple of (Drupal 8.9.13 and Drupal 9 based) sites where I use TB Megamenu megamenu module (https://www.drupal.org/project/tb_megamenu) to create the menu. All is working fine on ...
3
votes
2answers
6k views

How to render a field collection?

How can I properly render a field collection ? Is there any specific function for that ? I tried field_view_field but it does not output children fields. My field collection is attached to a line ...
1
vote
1answer
354 views

How to remove default form tag while rendering output in hook_theme

I am customizing the login form. I have to put all the three forms(login, register, forgotpassword) into one page. I don't want that unwanted root form tag, how can i remove that one? I am using ...
0
votes
2answers
391 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
0answers
20 views

CSS is not loading when create a new template node from newly created content type

The issue me having is that i cant able to successfully create a new page from newly create Content Type (if i use existing content types for create node template its working properly). i have tried ...
1
vote
1answer
647 views

How to display custom fields of taxonomy in field twig

In my content type for Event, I have an entity reference called Speakers which refers to a taxonomy called Team Members. It's set to multiple so I can say which speakers belong to my event. On ...
0
votes
1answer
484 views

Get the views field value

How to get the views field value and make a condition base on that field. Let say may views field is 'field_state' Example below: function my_module_views_pre_render(ViewExecutable $view) { //...
2
votes
3answers
918 views

Why a unnamed <div> is added to a specific region?

I have 2 blocks sitting in a region called "headline". Drupal 8 seems to add these 2 blocks , into an unnamed div and thus their display:flex CSS layout is cancelled (you can't scatter 2 container ...

1
2 3 4 5
210