Skip to content

Commit

Permalink
Allow node wrapper elements to be changed via preprocess.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacerider committed Sep 20, 2016
1 parent a6dacc5 commit 8f5d809
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
13 changes: 12 additions & 1 deletion fett.theme
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ function fett_preprocess_page(&$vars) {
fett_mobile_menu_preprocess_page($vars, $config);
}

/**
* Implements hook_preprocess_page().
*/
function fett_preprocess_node(&$vars) {
$vars['element'] = 'article';
$vars['title_element'] = 'h2';
$vars['link_title'] = TRUE;
$vars['content_element'] = '';
$vars['content_attributes'] = [];
}

/**
* This page preprocess function will be called after all other preprocessing
* has been completed.
Expand Down Expand Up @@ -211,7 +222,7 @@ function fett_menu_local_task(&$vars) {
}

$state = !empty($vars['element']['#active']) ? 'active' : 'secondary';
$link['url']->setOption('attributes', array('class' => array('button', $state)));
$link['url']->setOption('attributes', array('class' => array('button', 'admin', $state)));

// Iconify integration
if (isset($config['enable_extensions']) && $config['enable_extensions'] === 1) {
Expand Down
22 changes: 19 additions & 3 deletions templates/node/node.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,25 @@
* @see template_process()
*/
#}
<article id="node-{{ node.id }}" class="{{ attributes.class }}"{{ attributes }}>
<{{ element }} id="node-{{ node.id }}" class="{{ attributes.class }}"{{ attributes }}>
{{ title_prefix }}
{% if not page %}
<h2{{ title_attributes }}><a href="{{ url }}" rel="bookmark">{{ label }}</a></h2>
<{{ title_element }}{{ title_attributes }}>
{% if link_title %}
<a href="{{ url }}" rel="bookmark">
{% endif %}
{{ label }}
{% if link_title %}
</a>
{% endif %}
</{{ title_element }}>
{% endif %}
{{ title_suffix }}

{% if content_element %}
<{{ content_element}}{{ content_attributes }}>
{% endif %}

{% if display_submitted %}
<div class="posted">
{% if user_picture %}
Expand All @@ -98,4 +110,8 @@

{{ content.links }}
{{ content.comments }}
</article>

{% if content_element %}
</{{ content_element}}>
{% endif %}
</{{ element }}>

0 comments on commit 8f5d809

Please sign in to comment.