OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



URL link to galley in reading tool

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.

URL link to galley in reading tool

Postby newbies » Mon Jul 21, 2014 5:35 am

Hi,

I want to add URL links to HTML and PDF galley of an article in the reading tool block. I have difficulty coding the correct URLs pointing to HTML and PDF in the block.tpl file of readingTool plugin. I tried copying the code for generating those URL from article template to block template, but the code does not work there. Can anyone give me a piece of code that can generate URL to HTML and PDF in the reading tool block based on article ID?

Thank you!
newbies
 
Posts: 86
Joined: Sat Feb 23, 2013 9:15 pm

Re: URL link to galley in reading tool

Postby asmecher » Mon Jul 21, 2014 9:31 am

Hi newbies,

These URLs are generated e.g. by this code in templates/article/article.tpl:
Code: Select all
{url page="article" op="view" path=$article->getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal)}
Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 9211
Joined: Wed Aug 10, 2005 12:56 pm

Re: URL link to galley in reading tool

Postby newbies » Mon Jul 21, 2014 2:03 pm

Hi Alec,

Thank you so much. So I insert this code into block.tpl
Code: Select all
<a href="{url page="article" op="view" path=$article->getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal)}">Full Text</a>


When the link is click, it loads the full text html page only. How can I write the url that point to PDF view or download?
newbies
 
Posts: 86
Joined: Sat Feb 23, 2013 9:15 pm

Re: URL link to galley in reading tool

Postby asmecher » Mon Jul 21, 2014 2:31 pm

Hi newbies,

That template code will generate a link to the current galley you're looking at; if it's HTML, then you'll see HTML when you click the link. If you want to go from the HTML to the PDF or vice versa, you'll have to loop through available galleys for the article and find the one you want, generating the link from that. See e.g. this discussion.

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

Re: URL link to galley in reading tool

Postby newbies » Mon Jul 21, 2014 3:13 pm

That works! Thank you so much.

here is the code I inserted into plugins/blocks/readingTool/block.tpl just in case someone else needs it:

Code: Select all
{foreach from=$article->getGalleys() item=mygalley name=galleyList}
         {if !$galley->isPdfGalley()}
            <div class="articleToolItem">
               <img src="{$baseUrl}/plugins/blocks/readingTools/icons/html.png" class="articleToolIcon" /> <a href="{url page="article" op="view" path=$article->getBestArticleId($currentJournal)|to_array:$mygalley->getBestGalleyId($currentJournal)}">Full Text</a>
            </div>
         {else}
            <div class="articleToolItem">
               <img src="{$baseUrl}/plugins/blocks/readingTools/icons/pdf.png" class="articleToolIcon" /><a href="{url page="article" op="download" path=$article->getBestArticleId($currentJournal)|to_array:$mygalley->getBestGalleyId($currentJournal)}">PDF</a>
            </div>
         {/if}
      {/foreach}
newbies
 
Posts: 86
Joined: Sat Feb 23, 2013 9:15 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 2 guests