首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用自定义模板的块插件模块

不使用自定义模板的块插件模块
EN

Drupal用户
提问于 2019-01-18 17:08:48
回答 1查看 1.1K关注 0票数 0

我正在努力获得我的自定义模块模板,以获得通过块插件。

我遵循了在:自定义块插件的小枝模板上给出的解决方案,但是不断地得到这个错误:

网站遇到了一个意外的错误。请稍后再试。模板"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

代码语言:javascript
复制
 'osmtheme',
            '#jsonDataLocations' => 'nhd some data',
            '#title' => 'nhd some title',
        );

        /*
         '#attach' => [
                'css' => '/css/openstreetmap.css',
                'js' => '/js/openstreetmap.js',
            ],
         */
    }
}

lrg_lrg模块

代码语言:javascript
复制
        array(
            'variables' => array(
                'title' => null,
                'jsonDataLocations' => null
            ),
            'template' => 'block--osmnhd'
        )
    );
}

模板/块--osmnhd.html.twig

代码语言:javascript
复制
{#
/**
 * @file
 * Some description
 */
#}

    {{ title }}
    {{ jsonDataLocations }}
EN

回答 1

Drupal用户

回答已采纳

发布于 2019-01-18 17:54:51

modules/custom/lrg_osm/src/templates/).目录必须始终是模块或主题根目录的直接子目录,在您的示例中是/modules/custom/lrg_osm/templates/ (而不是D1)。

票数 0
EN
页面原文内容由Drupal提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://drupal.stackexchange.com/questions/275350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档