-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Milestone
Description
Reference: https://www.drupal.org/node/1354#themepreprocess
We need to do two things here:
- Go as close to the one region setup that made Kalatheme so easy to use
- Convert the page.tpl.php to TWIG
Luckily John has converted some of this for another client using Bootstrap theme and some of the leg work is done.
If we need to convert the region blocks, here is anexample of how John did it before:
/**
* Implements hook_preprocess_HOOK() for page.html.twig.
*/
function THEME_preprocess_page(&$variables) {
// Get active theme
$theme = explode("/", \Drupal::theme()->getActiveTheme()->getPath());
$theme = end($theme);
// Load up the site branding block into a var.
// So we don't need to use a region or the block in content.
$brand = Block::load($theme . '_branding');
$variables['branding'] = \Drupal::entityManager()
->getViewBuilder('block')
->view($brand);
// Load up help block, same as above.
$help = Block::load($theme . '_help');
$variables['help'] = \Drupal::entityManager()
->getViewBuilder('block')
->view($help);
// Load up main menu, same as above.
$main_menu = Block::load($theme . '_main_menu');
$variables['main_menu'] = \Drupal::entityManager()
->getViewBuilder('block')
->view($main_menu);
// Load up user / account menu, same as above.
$acct_menu = Block::load($theme . '_account_menu');
$variables['acct_menu'] = \Drupal::entityManager()
->getViewBuilder('block')
->view($main_menu);
}
Here is the page.html.twig:
...
{%
set navbar_classes = [
'navbar',
theme.settings.navbar_inverse ? 'navbar-inverse' : 'navbar-default',
theme.settings.navbar_position ? 'navbar-' ~ theme.settings.navbar_position|clean_class : '',
]
%}
<header{{ navbar_attributes.addClass(navbar_classes) }} id="navbar" role="banner">
<div class="container">
<div class="navbar-header">
{{ branding }}
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">{{ 'Toggle navigation'|t }}</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<nav role="navigation">
{{ main_menu }}
</nav>
</div>
</div>
</header>
<main id="main" class="clearfix js-quickedit-main-content" role="main">
<section class="column container">
{{ breadcrumb }}
<a id="main-content"></a>
{{ messages }}
{{ help }}
{% if action_links %}
<ul class="action-links">{{ action_links }}</ul>
{% endif %}
</section>
<section class="container main-container">
{{ page.content }}
</section>
</main>
<footer></footer>
Metadata
Metadata
Assignees
Labels
No labels