我正在努力获得我的自定义模块模板,以获得通过块插件。
我遵循了在:自定义块插件的小枝模板上给出的解决方案,但是不断地得到这个错误:
网站遇到了一个意外的错误。请稍后再试。模板"modules/custom/lrg_osm/templates/block--osmnhd.html.twig“没有在Twig_Loader_Twig_Error_Loader->getCacheKey()中定义( themes/contrib/bootstrap/templates/block/block.html.twig).的第64行)Drupal\Core\Template\TwigEnvironment-->getTemplateClass("modules/custom/lrg_osm/templates/block--osmnhd.html.twig") (线路: 424)
我还试图以各种方式篡改小树枝文件的名称,但没有用。
我的模块文件结构与相关代码如下所示,如果有人能够指出我的方法的错误,请:
src/Plugin/Block/osmnhdlock.php
'osmtheme',
'#jsonDataLocations' => 'nhd some data',
'#title' => 'nhd some title',
);
/*
'#attach' => [
'css' => '/css/openstreetmap.css',
'js' => '/js/openstreetmap.js',
],
*/
}
}
lrg_lrg模块
array(
'variables' => array(
'title' => null,
'jsonDataLocations' => null
),
'template' => 'block--osmnhd'
)
);
}
模板/块--osmnhd.html.twig
{#
/**
* @file
* Some description
*/
#}
{{ title }}
{{ jsonDataLocations }}
发布于 2019-01-18 09:54:51
modules/custom/lrg_osm/src/
templates/).目录必须始终是模块或主题根目录的直接子目录,在您的示例中是/modules/custom/lrg_osm/templates/
(而不是D1
)。
https://drupal.stackexchange.com/questions/275350
复制相似问题