如何获取 'hook_preprocess_block' 中的当前区域 ID?
How can I get the current region id inside the 'hook_preprocess_block'?
如何获取 hook_preprocess_block()
中的当前区域 ID?
我尝试了以下代码,但似乎有问题。
function ThemeName_preprocess_block(&$variables) {
if ($variables['elements']['#region'] == "nav") {
$variables['attributes']['class'][] = 'SomeStyle';
}
}
$region = $variables['elements']['#configuration']['region'];
如何获取 hook_preprocess_block()
中的当前区域 ID?
我尝试了以下代码,但似乎有问题。
function ThemeName_preprocess_block(&$variables) {
if ($variables['elements']['#region'] == "nav") {
$variables['attributes']['class'][] = 'SomeStyle';
}
}
$region = $variables['elements']['#configuration']['region'];