Skip to content

Commit

Permalink
Merge pull request #42 from Islandora/41-theme-vars
Browse files Browse the repository at this point in the history
#41 theme variables
  • Loading branch information
seth-shaw-asu committed Mar 6, 2024
2 parents bdd6ec7 + 4dc683f commit 4dcbfc2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,56 @@ Configure contexts at "Administration » Structure » Context".
As noted previously, this is just one way to set up the Mirador viewer configurations. If, for example, you wanted to always use the Mirador viewer for pages and paged content, you could remove the "Mirador" condition from the "Node has term" condition in these contexts.


## Theme Variables

Mirador's appearance and behaviour is configured via settings passed
to the JavaScript application. Mainly in 'window' and 'workspace' configuration
array.

These can be specified via theme variables or by passing
them as arguments instantiating the Mirador block class.

To hide the close button via a theme hook:

```php
function mymodule_preprocess_mirador(&$variables) {
$variables['window_config']['allowClose'] = FALSE;
}
```

To make a minimal UI by instantiating the block:

```php
$block = \Drupal::service('plugin.manager.block')->createInstance($viewer . '_block', [
'iiif_manifest_url' => "/node/$manifest_nid/manifest-single",
'thumbnail_navigation_position' => 'hidden',
'window_config' => [
'allowClose' => FALSE,
'allowMaximize' => FALSE,
'allowTopMenuButton' => FALSE,
'allowWindowSideBar' => FALSE,
'hideWindowTitle' => TRUE,
'panels' => [
'info' => FALSE,
'attribution' => FALSE,
' canvas' => FALSE,
'annotations' => FALSE,
'search' => FALSE,
],
],
'workspace_config' => [
'allowNewWindows' => FALSE,
'isWorkspaceAddVisible' => FALSE,
'workspaceControlPanel' => [
'enable' => FALSE,
],

],
]);

```

See the Mirador FAQ for more options: https://github.com/ProjectMirador/mirador/wiki/M3---Mirador-3-Frequently-Asked-Questions

## Documentation

Expand Down
10 changes: 7 additions & 3 deletions islandora_mirador.module
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function islandora_mirador_theme() {
'variables' => [
'iiif_manifest_url' => NULL,
'mirador_view_id' => NULL,
'thumbnail_navigation_position' => 'far-bottom',
'window_config' => [],
'workspace_config' => [],
],
'template' => 'mirador',
],
Expand All @@ -46,7 +49,7 @@ function template_preprocess_mirador(&$variables) {
$enabled_plugins = $config->get('mirador_enabled_plugins');
$variables['#attached']['drupalSettings']['mirador']['enabled_plugins'] = array_filter(array_values($enabled_plugins));

$window_config = [];
$window_config = $variables['window_config'];
foreach ($mirador_plugins as $plugin_id => $plugin_definition) {
if ($enabled_plugins[$plugin_id]) {
$plugin_instance = $mirador_plugin_manager->createInstance($plugin_id);
Expand Down Expand Up @@ -78,9 +81,10 @@ function template_preprocess_mirador(&$variables) {
'windows' => [
[
'manifestId' => $variables['iiif_manifest_url'],
'thumbnailNavigationPosition' => 'far-bottom',
'thumbnailNavigationPosition' => $variables['thumbnail_navigation_position'],
],
]
],
'workspace' => $variables['workspace_config'],
];
}

Expand Down
7 changes: 7 additions & 0 deletions src/Plugin/Block/MiradorBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ public function build() {
],
];

if (!empty($this->configuration['thumbnail_navigation_position'])) {
$build['viewer']['#thumbnail_navigation_position'] = $this->configuration['thumbnail_navigation_position'];
}
if (!empty($this->configuration['window_config'])) {
$build['viewer']['#window_config'] = $this->configuration['window_config'];
$build['viewer']['#workspace_config'] = $this->configuration['workspace_config'];
}
return $build;
}

Expand Down

0 comments on commit 4dcbfc2

Please sign in to comment.