Skip to content

Commit

Permalink
#281: adding page template and preprocess for page assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Walker committed Jun 10, 2016
1 parent 1379a07 commit 5cb115f
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
30 changes: 30 additions & 0 deletions kalatheme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Drupal\kalatheme\Utility\KalathemeFrameworkGetter;
use Drupal\block\Entity\Block;

/**
* Implements hook_library_info_build().
Expand Down Expand Up @@ -35,6 +36,35 @@ function kalatheme_page_attachments_alter(array &$page) {
*/
function kalatheme_preprocess_page(array &$variables) {
KalathemeFrameworkGetter::initialize()->preprocessPage($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);
}

/**
Expand Down
88 changes: 88 additions & 0 deletions templates/system/page.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{#
/**
* @file
* Theme override to display a single page.
*
* The doctype, html, head and body tags are not in this template. Instead they
* can be found in the html.html.twig template in this directory.
*
* Available variables:
*
* General utility variables:
* - base_path: The base URL path of the Drupal installation. Will usually be
* "/" unless you have installed Drupal in a sub-directory.
* - is_front: A flag indicating if the current page is the front page.
* - logged_in: A flag indicating if the user is registered and signed in.
* - is_admin: A flag indicating if the user has permission to access
* administration pages.
*
* Site identity:
* - front_page: The URL of the front page. Use this instead of base_path when
* linking to the front page. This includes the language domain or prefix.
*
* Page content (in order of occurrence in the default page.html.twig):
* - messages: Status and error messages. Should be displayed prominently.
* - node: Fully loaded node, if there is an automatically-loaded node
* associated with the page and the node ID is the second argument in the
* page's path (e.g. node/12345 and node/12345/revisions, but not
* comment/reply/12345).
*
* Regions:
* - page.content: The main content of the current page.
*
* @see template_preprocess_page()
* @see html.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>

0 comments on commit 5cb115f

Please sign in to comment.