OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Open PDF from TOC and abstract pages; bypass article view

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Open PDF from TOC and abstract pages; bypass article view

Postby rootl » Tue Sep 24, 2013 5:02 pm

We need to be able to open PDFs in a new window or user's pdf viewer, *directly* from the TOC pages (...../issue/current/showTOC) and abstract pages.

Essentially, anywhere a user clicks a PDF link, we want the pdf to open up directly, instead of the user being directed to the embedded pdf page.

Which template files need to be changed? (I am pretty sure one of the files is templates/issue/issue.tpl)

What needs to be done to the code? ( I am knowledgeable in PHP and have customized OJS and OMP templates for other needs.)


We are running OJS 2.4.2

Thank you.
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby asmecher » Wed Sep 25, 2013 2:11 pm

Hi rootl,

Yes, templates/issue/issue.tpl is the file to change. You should see the loop that goes through all galleys:
Code: Select all
{foreach from=$article->getGalleys() item=galley name=galleyList}
    <a href="{url page="article" op="view" path=$articlePath|to_array:$galley->getBestGalleyId($currentJournal)}" class="file">{$galley->getGalleyLabel()|escape}</a>
    {if $subscriptionRequired && $showGalleyLinks && $restrictOnlyPdf}
        {if $article->getAccessStatus() == $smarty.const.ARTICLE_ACCESS_OPEN || !$galley->isPdfGalley()}
            <img class="accessLogo" src="{$baseUrl}/lib/pkp/templates/images/icons/fulltext_open_medium.gif" alt="{translate key="article.accessLogoOpen.altText"}" />
        {else}
            <img class="accessLogo" src="{$baseUrl}/lib/pkp/templates/images/icons/fulltext_restricted_medium.gif" alt="{translate key="article.accessLogoRestricted.altText"}" />
        {/if}
    {/if}
{/foreach}
This is responsible for generating the list of article galleys (e.g. HTML, PDF, etc). Note the code that checks whether the galley is PDF:
Code: Select all
... $galley->isPdfGalley() ...
The changes you make here will depend on what you want to do -- change the link in the article title? Change only the link to the PDF galley? -- but the Smarty code is fairly self-explanatory.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby rootl » Thu Sep 26, 2013 12:43 pm

Can you provide the Smarty URL syntax for the link so instead of going to the article page, the specific PDF opens up directly?

I have tried a few different methods but none work. Thank you so much.
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby asmecher » Thu Sep 26, 2013 12:46 pm

Hi rootl,

The URL should look something like this (adapted from templates/article/pdfViewer.tpl):
Code: Select all
{url op="viewFile" path=$article->getId()|to_array:$galley->getBestGalleyId($currentJournal)}
...so a link to it would look like...
Code: Select all
<a href="{url op="viewFile" path=$article->getId()|to_array:$galley->getBestGalleyId($currentJournal)}">PDF</a>

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby rootl » Thu Sep 26, 2013 4:07 pm

Hi,

I replaced this <a href="{url page="article" op="view" path=$articlePath|to_array:$galley->getBestGalleyId($currentJournal)}" class="file">{$galley->getGalleyLabel()|escape}</a>

with <a href="{url op="viewFile" path=$article->getId()|to_array:$galley->getBestGalleyId($currentJournal)}">PDF</a>

After updating, clearing all caches, refreshing the browser etc, clicking the PDF links on the TOC page now just returns me to the current journal page.

I reverted the issue/issue.tpl file and the files open back up in the embedded pdf viewer.

As a note, the journal is accessible without a subscription - no restrictions.

Anything else I can try? Did I replace the code incorrectly? Thanks.
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby asmecher » Thu Sep 26, 2013 4:08 pm

Hi rootl,

Can you compare the URL generated with the modification in place, with the URL that is on the PDF viewer's page for the "download" link?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby rootl » Thu Sep 26, 2013 6:42 pm

Hi Alec,

Here are original' file link codes and examples of generated links, followed by modifications and examples of generated links.

Note these are all on a development server so they are not directly accessible to the 'public' yet.


ORIGINAL issue/issue.tpl
<a href="{url page="article" op="view" path=$articlePath|to_array:$galley->getBestGalleyId($currentJournal)}" class="file">{$galley->getGalleyLabel()|escape}</a>

Example of generated link
<a href="http://libwindev.geneseo.edu:8080/ojsgeneseo/index.php/gandy/article/view/667/431" class="file">PDF</a>
Links work

ORIGINAL article/pdfViewer.tpl
<a class="action pdf" id="pdfDownloadLink" target="_parent" href="{url op="download" path=$articleId|to_array:$galley->getBestGalleyId($currentJournal)}">{translate key="article.pdf.download"}</a>

example of generated link
<a class="action pdf" id="pdfDownloadLink" target="_parent" href="http://libwindev.geneseo.edu:8080/ojsgeneseo/index.php/gandy/article/download/667/431">Download this PDF file</a>
Links work


MODIFIED issue/issue.tpl using copy of link from article/pdfViewer.tpl
<a class="action pdf" id="pdfDownloadLink" target="_parent" href="{url op="download" path=$articleId|to_array:$galley->getBestGalleyId($currentJournal)}">{translate key="article.pdf.download"}</a>

Resulting Generated link:
<a class="action pdf" id="pdfDownloadLink" target="_parent" href="http://libwindev.geneseo.edu:8080/ojsgeneseo/index.php/gandy/issue/download/667/431">Download this PDF file</a>
Result: Clicking this link returns user to 'current' issue page, pdf does not download


MODIFIED issue/issue.tpl using link syntax from forum thread:
<a href="{url op="viewFile" path=$article->getId()|to_array:$galley->getBestGalleyId($currentJournal)}">PDF</a>

Resulting Generated link:
<a href="http://libwindev.geneseo.edu:8080/ojsgeneseo/index.php/gandy/issue/viewFile/667/431">PDF</a>
Result: Clicking this link returns user to 'current' issue page.
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby asmecher » Fri Sep 27, 2013 8:27 am

Hi rootl,

Ah -- I see the problem. Add:
Code: Select all
page="article"
...to the {url ...} tag that generates the article download link.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Re: Open PDF from TOC and abstract pages; bypass article vie

Postby rootl » Mon Sep 30, 2013 5:22 am

Thank you very much! That worked.

I have added code for options to be able to directly view the pdf or download it. Both work perfectly. If anyone wants to use it, it is here:

Line 44 of issue/issue.tpl
<a href="{url page="article" op="viewFile" target="_blank" path=$articleId|to_array:$galley->getBestGalleyId($currentJournal)}" class="file">View {$galley->getGalleyLabel()|escape}</a> &nbsp;|&nbsp;<a href="{url page="article" op="download" path=$articleId|to_array:$galley->getBestGalleyId($currentJournal)}" class="file">Download {$galley->getGalleyLabel()|escape}</a>

Here is a screenshot of the TOC page of the journal. We will definitely submit the journal to the 'showcase' when we launch.
Attachments
gandy.PNG
gandy.PNG (47.15 KiB) Viewed 929 times
rootl
 
Posts: 62
Joined: Wed Feb 20, 2013 7:17 am


Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 2 guests