【问题标题】:Theming rss in drupal 9drupal 9 中的 rss 主题
【发布时间】:2022-12-13 17:46:02
【问题描述】:

我对 Views RSS 生成的 RSS 提要有一个谜 在 Drupal 9 项目中,我有一个自定义主题。在这个自定义主题中,我有 网页/主题/自定义/CUSTOM_theme/templates/views-view-row-rss.html.twig 但它从未被 Drupal 使用。 在 CUSTOM_theme.theme 我有

function CUSTOM_theme_registry_alter(&$theme_registry) {
echo '<pre>';
var_dump($theme_registry['views_view_row_rss']);
echo '</pre>';

}

主题的路径很好.. [“路径”]=> string(34) “主题/自定义/CUSTOM_theme/模板”

但是在 web/core/lib/Drupal/Core/Theme/ThemeManager.php 中我为钩子 views-view-row-rss 添加(仅用于测试,当然我不想修改此文件)

      echo  '<pre>';
      var_dump($info);

结果说路径是

[“路径”]=> 字符串(35)“模块/贡献/views_rss/模板”

更神秘的是,在这两种情况下,thme_path 都很好 [“主题路径”]=> string(24) “主题/自定义/CUSTOM_theme”...

你知道如何纠正这个问题并使用 web/themes/custom/CUSTOM_theme/templates/views-view-row-rss.html.twig

谢谢

【问题讨论】:

    标签: drupal themes rss


    【解决方案1】:

    好吧,多亏了他,有人发现了 Discord 上的问题。

    
    /
     * Implemenents hook_theme_registry_alter().
     */
    function views_rss_theme_registry_alter(array &$registry) {
      // Use the twig file that comes with this module so that the CDATA wrapper can
      // be added.
      $module_dir = Drupal::service('extension.list.module')->getPath('views_rss');
      $registry['views_view_row_rss']['path'] = $module_dir . '/templates';
    }
    

    该模块将每次搜索 views_rss 上的路径。 所以,解决方案是做

    function CUSTOM_theme_registry_alter(array &$registry) {
      // Use the twig file that comes with this module so that the CDATA wrapper can
      // be added.
      $module_dir = Drupal::service('extension.list.theme')->getPath('NAME OF THEME');
      $registry['views_view_row_rss']['path'] = $module_dir . '/templates';
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多