Reputation: 3
I have a content type as "news". for this content type i need to show latest 5 articles. so i created block by using views. it is showing articles finely but i need to add my own css using twig files. i tried following options but none of them worked correctly.
block--newsblock.html.twig
block--newsblock-block.html.twig
views--view-newsblock-block.html.twig
But when i applied in following way , the field template is calling.
views-view-fields--newsblock--block.html.twig
What i want is for first element in block i need to show some teaser text for rest of them i need to show only title. how can i do it?
Upvotes: 0
Views: 289
Reputation: 7289
activate twig debug and look at your console it will tell you suggestions of file names to use
Alternatively add this hook to your_theme_name.theme to proppose your own suggestion
/**
* Implements hook_theme_suggestions_HOOK_alter() for block templates.
*/
function your_theme_theme_suggestions_block_alter(array &$suggestions, array $variables) {
$block_id = $variables['elements']['#id'];
/* Uncomment the line below to see variables you can use to target a block */
// print $block_id . '<br/>';
/* Add classes based on the block id. */
switch ($block_id) {
case 'your_block_id':
$suggestions[] = 'block__newsblock';
break;
}
}
it will be then block--newsblock.html.twig
Upvotes: 1