File name suggessations are as follows:
{{kint(product_info)}}
[base template name]--[view machine name]--[view display id].html.twig
[base template name]--[view machine name]--[view display type].html.twig
[base template name]--[view display type].html.twig
[base template name]--[view machine name].html.twig
[base template name].html.twig
[base template name]--[view machine name]--[view display type].html.twig
[base template name]--[view display type].html.twig
[base template name]--[view machine name].html.twig
[base template name].html.twig
example I used for an "unformatted list" with machine name "view_name" and with a single block, "block_1"
views-view-unformatted--view-name--block-1.html.twig
views-view-unformatted--view-name--block-1.html.twig
Custom Theme template with modules
module name = product_view
Add .module file
/**
* Implements hook_theme().
*/
function product_view_theme() {
return [
'product_view' => [
'variables' => [
'product_info' => [],
],
],
];
}
In controller return the theme with data::
$aa = array('name' => 'raj','age' => 20);
$render_array = [
'#theme' => 'product_view',
'#product_info' => $aa,
'#title' => $this->t('Argument Information'),
];
return $render_array;
in twig file you can get the values::
Heelo test
{{kint(product_info)}}
Comments
Post a Comment