Skip to content
Snippets Groups Projects
Commit bc09ae89 authored by Pooja Sharma's avatar Pooja Sharma
Browse files

Resolve #3444843 "Integrate tour with navigation"

parent 121bc297
No related branches found
No related tags found
1 merge request!68Resolve #3444843 "Integrate tour with navigation"
Pipeline #278161 passed with warnings
{#
/**
* @file
* Default theme implementation to display the tour navigation item.
*
* Available variables:
* - content: The content of this navigation_tour_block.
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('toolbar-block') }}>
{% block content %}
{% set attr = content['#attributes'] %}
{% include '@navigation/toolbar-button.html.twig' with {
attributes: attributes.setAttribute('data-drupal-tooltip', content['#value'])
.setAttribute('type', content['#tag']).setAttribute('class', attr.class)
.setAttribute('aria-haspopup', attr['aria-haspopup'])
.setAttribute('disabled', attr.disabled),
icon: 'help',
html_tag: content['#tag'],
text: content['#value'],
} only %}
{% endblock %}
</div>
......@@ -231,3 +231,35 @@ function tour_tour_tips_alter(array &$tour_tips, EntityInterface $entity): void
}
}
}
/**
* Implements hook_preprocess_HOOK() for navigation.html.twig.
*/
function tour_preprocess_navigation(&$variables) {
if (isset($variables['content']['content'])) {
$tour_block = \Drupal::service('plugin.manager.block')->createInstance('tour_button_block', []);
$tour = $tour_block->build();
$variables['content']['content']['tour'] = [
'#theme' => 'block__navigation__tour',
'#configuration' => $tour_block->getConfiguration(),
'#plugin_id' => $tour_block->getPluginId(),
'#base_plugin_id' => $tour_block->getBaseId(),
'#derivative_plugin_id' => $tour_block->getDerivativeId(),
'#in_preview' => FALSE,
'#weight' => 0,
'content' => $tour['content'],
];
}
}
/**
* Implements hook_theme().
*/
function tour_theme($existing, $type, $theme, $path) {
$items['block__navigation__tour'] = [
'render element' => 'elements',
'base hook' => 'block',
];
return $items;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment