Skip to content

Commit

Permalink
Merge pull request #195 from isubit/development
Browse files Browse the repository at this point in the history
Development 1.7.5
  • Loading branch information
sacarney authored May 4, 2022
2 parents eb79e8e + 79d59d0 commit e485962
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 3 additions & 1 deletion iastate_theme.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Drupal 9 theme for Iowa State University websites
type: theme
core: 8.x
core_version_requirement: ^8 || ^9
version: "1.7.4"
version: "1.7.5"
base theme: stable
libraries:
- iastate_theme/global-css
Expand All @@ -26,9 +26,11 @@ regions:
menu_navbar: 'Menu Navbar'
post_nav: 'Post Nav'
breadcrumbs: 'Breadcrumbs'
hero_top: 'Hero Top'
content: 'Page Content'
sidebar_first: 'Sidebar First'
sidebar_second: 'Sidebar Second'
hero_bottom: 'Hero Bottom'
footer_first: 'Footer First'
footer_second: 'Footer Second'
footer_third: 'Footer Third'
Expand Down
21 changes: 19 additions & 2 deletions iastate_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@ use Drupal\Core\Form\FormStateInterface;
/**
* Implements template_preprocess_html().
*
* Add node-id_{id} class.
*/
function iastate_theme_preprocess_html(&$variables) {

/* Add node-id_ and node-type_ classes to body */
$node = \Drupal::request()->attributes->get('node');
if ($node instanceof NodeInterface) {
$variables['attributes']['class'][] = 'node-id_' . $node->id();
}
if (isset($variables['node_type'])) {
$variables['attributes']['class'][] = 'node-type_' . $variables['node_type'];
}

/* Add views classes to body */
$route = \Drupal::routeMatch()->getRouteObject();
$view_id = $route->getDefault('view_id');
$display_id = $route->getDefault('display_id');

if ($view_id) {
$variables['attributes']['class'][] = 'view_' . $view_id;
$variables['attributes']['class'][] = 'view-display_' . $display_id;
}
}

/*
Expand Down Expand Up @@ -160,16 +171,22 @@ function iastate_theme_preprocess(&$variables, $hook) {
/*
* Implements theme_preprocess_block().
*
* Make theme settings available in block templates
*/

function iastate_theme_preprocess_block(&$variables) {
// Make theme settings available in block templates
$variables['iastate_logo_alt'] = theme_get_setting('iastate_logo_alt');
$variables['iastate_logo_width'] = theme_get_setting('iastate_logo_width');
$variables['iastate_logo_height'] = theme_get_setting('iastate_logo_height');
$variables['iastate_logo_alt'] = theme_get_setting('iastate_logo_alt');
$variables['is_default_logo'] = \Drupal::config('iastate_theme.settings')->get('logo.use_default');
$variables['iastate_logo_url'] = theme_get_setting('iastate_logo_url');

// Make block type available in block templates
if ($variables['elements']['#base_plugin_id'] == 'block_content') {
$blockType = strtr($variables['content']['#block_content']->bundle(), '_', '-');
$variables['attributes']['class'][] = 'block-type_' . $blockType;
}
}

/*
Expand Down
1 change: 1 addition & 0 deletions templates/layout/html.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
is_node_edit == 'edit' ? 'node-form node-form_' ~ 'edit',
is_node_add == 'add' ? 'node-form node-form_' ~ 'add',
is_node_delete == 'delete' ? 'node-form node-form_' ~ 'delete',
is_front ? 'is_front' : 'not_front',
]
%}
<body{{ attributes.addClass(body_classes) }}>
Expand Down
8 changes: 8 additions & 0 deletions templates/layout/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@

{{ page.breadcrumbs }}

{% if page.hero_top %}
{{ page.hero_top }}
{% endif %}

<div class="container">
<div class="row">

Expand Down Expand Up @@ -117,6 +121,10 @@
</div>
</div>

{% if page.hero_bottom %}
{{ page.hero_bottom }}
{% endif %}

</main>

{% include '@iastate_theme/parts/footer.html.twig' %}
Expand Down

0 comments on commit e485962

Please sign in to comment.