Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. use DrupalblockEntityBlock;
  2.  
  3. /**
  4. * Implements hook_preprocess_region().
  5. */
  6. function MYTHEME_preprocess_region(&$variables) {
  7. if ($variables['region'] == 'one_page') {
  8. $blocs_menu = array();
  9. foreach ($variables['elements'] as $key => $values) {
  10. if (substr($key, 0, 1) == '#') {
  11. continue;
  12. }
  13. $bloc_object = Block::load($key);
  14. if (is_object($bloc_object)) {
  15. $bloc_settings = $bloc_object->get('settings');
  16. if ($bloc_settings['label_display']) {
  17. $blocs_menu[] = array(
  18. 'id' => $key,
  19. 'label' => $bloc_settings['label'],
  20. );
  21. }
  22. }
  23. }
  24. if (count($blocs_menu)) {
  25. $variables['region_menu'] = $blocs_menu;
  26. }
  27. }
  28. }
  29.  
  30. {%- if region_menu -%}
  31. <nav class="page-nav-anchor">
  32. <ul>
  33. {%- for menu in region_menu -%}
  34. <li><a rel="scroll" href="#block-{{ menu['id'] }}">{{ menu['label'] }}</a></li>
  35. {%- endfor -%}
  36. </ul>
  37. </nav>
  38. {%- endif -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement