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
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
newbies
Posts: 87
Joined: Sat Feb 23, 2013 9:15 pm

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!

asmecher
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm
Contact:

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

newbies
Posts: 87
Joined: Sat Feb 23, 2013 9:15 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?

asmecher
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm
Contact:

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

newbies
Posts: 87
Joined: Sat Feb 23, 2013 9:15 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}


Return to “OJS Technical Support”

Who is online

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