Drupal 8: Twig Grouping Template - drupal

How to overwrite views-view-grouping.html.twig template, when I habe view called "My view" and I am grouping rows with taxonomy term "Format"?
Thanks in advance!

Template file should be named as views-view-grouping--[view machine name]--[view block id].html.twig.
Enable twig debug in drupal 8 to get more helps regarding templates.

Related

how to use fields from custom block in drupal 8

Im new to drupal 8. This is my first time building a site so please help. I have created a custom block type by going to structure/block layout/ types/ add custom block type - 'Feature Boxes'. This block type has 4 fields for the 4 dif images, and 4 fields for the 4 dif links. How can i use the data from each field in my page--front.html.twig file.
Use this module:
Twig Tweak
Examples can be found here:
I'm not familiar with adding fields to blocks.

Output image field in Twig and D8

I created a basic page with a NID of 176. My basic page content type contains a field called field_banner_image.
In my templates directory I created a file called page--node--176.html.twig and the template works.
I saw a few threads where you can access the node content via {{ content.field_name }}, however, my content appears to NULL every time.
I managed to output the URL of my image field via:
{{ file_url(node.field_banner_image.entity.uri.value) }}
I feel like there has to be an easier/better way of doing this. Any suggestions? Why is content null in my twig templates?
If your template is named page--node--176.html.twig, it is actually a page template overriding the base page template page.html.twig, so you will have access to all page variables but not those in your node.
Although your node type is called "page", it is still a node, and the template for it would be node--176.html.twig which overrides node.html.twig.
In your node--***.html.twig you will have access to the content variable. Let me know if you need help.

Theming node add form

I want to theme this page node/add/classified.
I tried creating page--node--add.tpl.php, page--classified--add.tpl.php, page--node--classified--add.tpl.php refreshing cache all the time...Nothing works
I tried also implementing hook_theme() and hook_preprocess_page().
If you want to create a tpl file for a particular content type as you mentioned in your post "node/add/classified", then I would suggest, you should go with the tpl name like this
Drupal 6 : page-node-add-[content type].tpl.php
Drupal 7 : page--node--add--[content type].tpl.php
in your case, this would be (assuming your Drupal version is 7.x):
page--node--add--classified.tpl.php
Hope it will help you.

Drupal 6 theme add / edit content form

Drupal 6 theme add / edit content form
In Drupal 6, we can add new content type "content-type".
We want to theme /node/add/content-type by template file.
We want to theme the edit form /node/$nid/edit of this content-type also by template file.
How to do this?
For this you need to understand the naming convention of tpl files in Drupal. This link will help https://www.drupal.org/node/1089642
According to documentation,
"http://www.example.com/node/1/edit" would result in the following suggestions:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php
Either you can try adding content-type in the naming as suggested(I have not tried it personally), or if there are few customization to be done, adding a check like
<?php if($node->type == 'content_type_name') ?>
over available variables in "page-node-edit.tpl.php" will also do.

Drupal Theming - Different themes for each webform

I am including a webform block in a page using module invoke.
The block is included as a node, and says "Submitted by admin on Wed, 2010-01-20 14:06" on top of the form. The devel template information is as follows:
Template called:
node.tpl.php
File used:
sites/all/themes/david01/node.tpl.php
Candidate template files:
node-webform.tpl.php < node.tpl.php
I know how to theme the webform (webform-form-###.tpl.php), but how do I theme this node in particular (node-webform-####.tpl.php is not a candidate!)
Try to define node-[nid].tpl.php - a template for a single node.
Also look through this post.

Resources