Changing Default Viewer to Universal Viewer?

I’d like to come more up-to-speed regarding UI or theme customization but for now I hope this will be a relatively straightforward question.
When using the IIIF Module than enables the Universal Viewer how do I change the default behavior so that an item page uses only the Universal Viewer and not both
the default Open Seadragon viewer at the top half of the item page and Universal Viewer in the bottom half of the page? Currently testing the Center Row theme and need only one viewer to be active.

Thanks.

Carl

The widget is automatically added to the theme to simplify the work of the theme designer.

You “just” have to update the file themes/CenterRow/view/omeka/site/item/show.phtml.

  • Remove or comment the existing div block that displays OpenSeaDragon and the list of media, and the associated javascript.
  • Disable the option in the config of Universal Viewer to not append it automatically.
  • Add <?php echo $this->universalViewer($item); ?> where you want, and see readme to specify options if needed.
1 Like

Thanks, Daniel, I’ll give this a try.

Carl

I’m just curious as I haven’t seen a specific theme that does this: Are there any base themes out there that are geared towards displaying Universal Viewer by default?

No, the distributed modules all use OpenSeadragon as the default viewer. Universal Viewer is added as a module (https://github.com/Daniel-KM/Omeka-S-module-UniversalViewer). I believe UV was initially distributed as part of the IIIF Server module but then the two were separated.

FWIW, I’m still trying to get UV to work with an external IIIF image server but haven’t visited the latest docs.

I’m on OS X but running Omeka-S under Vagrant (emulating Ubuntu Linux). In planning to clone my Vagrant Omeka-S instance and doing a beta version 4 update then I’ll get right back to UV and IIIF server.

Carl

1 Like

Daniel,

Upgraded to beta4. Tried to follow your instructions (and making progress) but still seeing both OpenSeadragon and UV. Sounds straightforward but I’m new to PHP. Could you post a working example of that section of the show.phtml file?

Thanks.

There is no option to disable the default viewer, so you have to disable it manually. So on the original file (see https://github.com/omeka-s-themes/centerrow/blob/master/view/omeka/site/item/show.phtml), you have to remove or comment lines 16 to 29 and lines 34 to 41.

To add the universal viewer, replace lines 34 to 41 by:

<?php if ($item->media()): ?>
    <?php echo $this->universalViewer($item); ?>
<?php endif; ?>

You can move this block anywhere in the page.

Daniel,

Yes, that works.

Thanks!

Carl

I’m really struggling with this - my line numbers don’t match those that Daniel_Km point to - so I’m not sure if the github has changed and thus the lines aren’t right…can anyone provide me with a sample show.phtml that works - also what has to be done in the config of the universal viewr module. Please and thank you!

Each theme is different and evolves, so you need to adapt yours. If you use center row and want to replace the default viewer, remove all the css and js in the header, then, because Universal Viewer displays all the files of an item, you just need to check if it can read all the medias, so it’s not recommended to mix media that uv can read and others.
So replace line https://github.com/omeka-s-themes/centerrow/blob/master/view/omeka/site/item/show.phtml#L13-L22 by :

$useUniversalViewer = true;
foreach ($item->media() as $media) {
    $mediaType = $media->mediaType();
    $mediaRenderer = $media->renderer();
    if (strpos($mediaType, 'image/') === false 
        && $mediaType !== 'application/pdf' 
        && $mediaRenderer !== 'iiif'
    ) {
       $useUniversalViewer = false;
       break;
    }
}

Then display it, replacing lines https://github.com/omeka-s-themes/centerrow/blob/master/view/omeka/site/item/show.phtml#L26-L42:

<?php if ($useUniversalViewer): ?>
<?php echo $this->universalViewer($item); ?>
<?php endif; ?>

<?php echo $item->displayValues(); ?>

<?php if (!$useUniversalViewer): ?>
<div id="other-media" class="property">
    <h4><?php echo $this->translate('Other Media'); ?></h4>
    <?php foreach($item->media() as $media): ?>
        // No change after.

Ideally, UniversalViewer or any viewer would replace automatically the renderer, but this is not the case currently.

1 Like

another problem I’m having is the show.phtml in the centerrow theme isn’t what is being used (I can rename that and it has no affect on the rendering) instead the show.phtml that is being used is:
omeka-s\application\view\omeka\site\item

I found this article https://omeka.org/s/docs/developer/themes/modifying_themes/ but it is not clear to me that following the instructions will mean the theme version will override the one in the application folder.

and since the show.phtml is completely different in application than in the theme, I cannot replace the default viewer with the universal viewer

If the template file is not present in your theme directory, Omeka takes the default one inside application/view/. So if you want to customize it, just copy it in your theme at the good place, and modify it. This is the same for the views created by the modules.

so I solved this issue with one line of CSS - while the universal viewer is still below the info on the page - at least the other viewer doesn’t show- I plan to fiddle with the CSS some more - but this solution did what I needed it to do - just show one viewer.

.media-render {
display:none
}

Hi all,

I’m currently attempting to do the same thing. I had no problem removing the default viewer and adding the Universal Viewer through the PHP above, but am a little confused as to what config setting for the Universal Viewer needs to be changed to remove the appended version at the bottom of the item page.

I tried editing line 84 of module.config.php under site settings to read:

universalviewer_append_item_show’ => false

but it didn’t seem to have an effect.

Any help would be appreciated!

Thanks very much,

Tristan

tdahn,

I was having the same problem and I finally figured it out. You need to go to the Settings page for you site and uncheck “Append automatically to item page” under the Unviersal Viewer section.

2 Likes

Thanks! Of course it would be something that easy. It’s good to know that the rest of the settings are available there as well.

Daniel, thanks for the the code snippets which does work as advertised. I don’t know how theme specific this is but, thinking out loud, wondering if perhaps as a future enhancement there’s a way to make this a more easily accessible option, either in the documentation or perhaps through the UI?

Ideally, the Universal viewer (and the other viewers I just published : Mirador and Diva) should be used by default when it is an image or an iiif, like it is with the pdf viewer, or the OpenDocument viewer. But it has some impact on other parts of Omeka S, so currently, they are only a view helper that can be added by theme creators.