Lising accessible viewers, or registering one?

Hello,

I am trying to modifing the item file to use a different viewer depending on my file type.

Reading the file i currently have, i see this

        elseif (count($medias) !== 0): ?>
        <?php echo $this->universalViewer($item); ?>

Reading this, i understand that we call the universalViewer function, since it’s a plugin we installed, to render our $item.
I can check what’s returned, some html code.
I can’t print $this and manually check everything around.

I would like to use pdf.js to render pdf files, but i don’t want to just disable universal viewer. I woudl like to be able to call something like

if $item == pdf
    $this->pdfJs($item)

I was trying to use Daniel km’s pdf viewer, but i can’t see the usage that i need, or the part that defines the function in uv’s style. (Daniel-KM / Omeka-S-module-PdfViewer · GitLab)

Can anyone help me ?

Thanks

The methods avaiable on $this are mostly view helpers some coming from Laminas (our underlying framework), some from the Omeka S core, and some from modules.

Omeka S contains a built-in capability to have media viewers that are based on a file’s mimetype and/or extension, but the Universal Viewer is a different system that kind of sidesteps Omeka S’s normal media display. The PDF viewer module from @Daniel_KM that you’re looking at here uses the “normal,” built-in system to register a viewer for PDF files (there are some other PDF viewer modules that work similarly).

If you mostly have items that either you just want to use Universal Viewer on or just PDFs, and there isn’t much mixture of multiple filetypes in a single item (or mostly you have just one media for each item), then you can probably just write an if statement that checks for PDFs and decides to use the normal Omeka media display method instead, something like:

foreach ($medias as $media):
    echo $media->render();
endforeach;

If you do want to have both at the same time then you’d have to use a different solution. I believe Universal Viewer can display PDFs itself, but I’m not the best source of information on that.

1 Like

Yes, universal viewer can display pdf (it has pdf.js inside it).
The aim of the pdf viewer i wrote is that it does not use the pdf reader of the browser, so it is themable. If you don’t need to customize the pdf viewer, you can use the simpler one that is present on omeka.org.
And unlike Universal viewer, the pdf viewer is rendered directly as a media, there is no helper.

1 Like

Thanks @jflatnes, i’ll be sure to read that! Sometimes i get stuck like this looking for the “magic word”

@Daniel_KM Hello, i saw that UV can display PDF files, but i need more complex features that UV doesn’t (afaik) have, like pdf toc, text search and everything.

Thanks! I’ll update this thread with my solution

1 Like

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.