Python - Dont Use Static or Class variables with Self
While doing code review of one of junior, I encountered following code: What…
April 10, 2020
Suppose you have a view, and you have configured your display as a table. Drupal provides no way to configure a css class for the table. And, it shows an ugly table. I was using bootstrap css, and they have some really awesome table classes. Lets see how we can add that custom class to a table view.
See the earlier table:
So, there is no way on the drupal configuration to do that. We need to do little bit of twig file tweak. First, we need to see from which twig file, the output is being rendered.
debug: false
Now refresh the page, and inspect the html in chrome. You will see from where the html is coming. In my case, it was showing the view name as:
/core/themes/classy/templates/views/views-view-table.html.twig
Copy that twig file in your theme’s template directory. And, edit that file. You will see a section on top where classes are being set, see below:
set classes = [
'views-table',
'views-view-table',
'cols-' ~ header|length,
responsive ? 'responsive-enabled',
sticky ? 'sticky-enabled',
]
In bootstrap, the simple class for the table is: table Simply add that class in the list, and nothing else. See changes below:
set classes = [
'views-table',
'views-view-table',
'table',
'cols-' ~ header|length,
responsive ? 'responsive-enabled',
sticky ? 'sticky-enabled',
]
Save the file. Now, clear the cache. And, refresh your page. You should see the expected changes in your html.
See the bootstrap version of the table view
While doing code review of one of junior, I encountered following code: What…
I have a custom content type, and there are around 2000 number of nodes in my…
Introduction In your backend and frontend projects, you always need to deal with…
Introduction I have my main website, which I run on Lets say: . Now, there is my…
Introduction There are some cases, where I need another git repository while…
hook_cron() suggests to put tasks that executes in shorter time or non-resource…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…