【问题标题】:How can I get the current region id inside the 'hook_preprocess_block'?如何获取当前区域位于“hook_preprocess 块”内?
【发布时间】:2017-12-19 16:39:56
【问题描述】:

如何获取hook_preprocess_block()中的当前区域ID?
我尝试了以下代码,但似乎有问题。

function ThemeName_preprocess_block(&$variables) {
  if ($variables['elements']['#region'] == "nav") {
    $variables['attributes']['class'][] = 'SomeStyle';
  }
}

【问题讨论】:

    标签: drupal hook block preprocessor theming


    【解决方案1】:

    $region = $variables['elements']['#configuration']['region'];

    【讨论】:

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