Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use DrupalblockEntityBlock;
- /**
- * Implements hook_preprocess_region().
- */
- function MYTHEME_preprocess_region(&$variables) {
- if ($variables['region'] == 'one_page') {
- $blocs_menu = array();
- foreach ($variables['elements'] as $key => $values) {
- if (substr($key, 0, 1) == '#') {
- continue;
- }
- $bloc_object = Block::load($key);
- if (is_object($bloc_object)) {
- $bloc_settings = $bloc_object->get('settings');
- if ($bloc_settings['label_display']) {
- $blocs_menu[] = array(
- 'id' => $key,
- 'label' => $bloc_settings['label'],
- );
- }
- }
- }
- if (count($blocs_menu)) {
- $variables['region_menu'] = $blocs_menu;
- }
- }
- }
- {%- if region_menu -%}
- <nav class="page-nav-anchor">
- <ul>
- {%- for menu in region_menu -%}
- <li><a rel="scroll" href="#block-{{ menu['id'] }}">{{ menu['label'] }}</a></li>
- {%- endfor -%}
- </ul>
- </nav>
- {%- endif -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement