diff --git a/iastate_theme.info.yml b/iastate_theme.info.yml index 7bfe230..a7aae13 100644 --- a/iastate_theme.info.yml +++ b/iastate_theme.info.yml @@ -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 @@ -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' diff --git a/iastate_theme.theme b/iastate_theme.theme index aa1e972..d85ab4f 100644 --- a/iastate_theme.theme +++ b/iastate_theme.theme @@ -6,9 +6,10 @@ 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(); @@ -16,6 +17,16 @@ function iastate_theme_preprocess_html(&$variables) { 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; + } } /* @@ -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; + } } /* diff --git a/templates/layout/html.html.twig b/templates/layout/html.html.twig index 858e2f3..d56d485 100644 --- a/templates/layout/html.html.twig +++ b/templates/layout/html.html.twig @@ -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', ] %} diff --git a/templates/layout/page.html.twig b/templates/layout/page.html.twig index 4c45f8f..f62ee80 100644 --- a/templates/layout/page.html.twig +++ b/templates/layout/page.html.twig @@ -79,6 +79,10 @@ {{ page.breadcrumbs }} + {% if page.hero_top %} + {{ page.hero_top }} + {% endif %} +
@@ -117,6 +121,10 @@
+ {% if page.hero_bottom %} + {{ page.hero_bottom }} + {% endif %} + {% include '@iastate_theme/parts/footer.html.twig' %}