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