OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Generate URL for Full Text

OJS development discussion, enhancement requests, third-party patches and plug-ins.

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.

Generate URL for Full Text

Postby tomp » Wed Nov 30, 2011 10:46 pm

Hi,

I am dynamically displaying a list of most recent articles on my journal homepage using a modified version of the 'popularArticles' plugin.

I'd like each article in the list to be linked to the Full Text galley, but I'm not clear how to generate the appropriate URL for the Full Text.

Can anyone help? At the moment, the best that I can do is generate a URL for the abstract...

Many thanks,
Tom
tomp
 
Posts: 5
Joined: Wed Jun 29, 2011 12:33 pm

Re: Generate URL for Full Text

Postby jmacgreg » Mon Dec 05, 2011 11:37 am

Hi Tom,

I'm not sure how the Popular Articles plugin generates URLs, but you may want to take a look at that plugin's block.tpl for a general idea, and then look at the ToC template file (templates/issue/issue.tpl, IIRC) to see how full-text article links are generated. Let us know if you have any further questions.

Cheers,
James
jmacgreg
 
Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

Re: Generate URL for Full Text

Postby tomp » Mon Dec 05, 2011 10:33 pm

Hi James,

The code that generates the URL in issue.tpl is:

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

So it looks like I need to access getBestGalleyID from within my plugin. I assume this will involve editing an associated handler, but I'm not sure which handler it would be.

IndexHandler.inc.php perhaps? Are you able to suggest what should be added to the handler to enable me to access getBestGalleyID from within the plugin?

Many thanks for your help,

Tom
tomp
 
Posts: 5
Joined: Wed Jun 29, 2011 12:33 pm

Re: Generate URL for Full Text

Postby tomp » Mon Jan 23, 2012 10:10 am

Hi,

I still haven't found a solution to this. Can anyone help?

Thanks!
Tom
tomp
 
Posts: 5
Joined: Wed Jun 29, 2011 12:33 pm

Re: Generate URL for Full Text

Postby jmacgreg » Sat Jan 28, 2012 7:00 pm

Hi Tom,

Apologies for not getting back sooner -- I thought I had, but I must've just missed it.

You'll find the following in pages/issue/IssueHandler.inc.php:

Code: Select all
            $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true);
            $templateMgr->assign_by_ref('publishedArticles', $publishedArticles);


This code provides the issue.tpl file with a $publishedArticles variable than includes all published articles. You'll have to add this to your plugin's class file -- see other plugins for examples of how this is done. Once you have this $publishedArticles variable available to you, you should be able to do something like:

Code: Select all
{foreach from=$publishedArticles item=article}
   {assign var=articlePath value=$article->getBestArticleId($currentJournal)}
   {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>
   {/foreach}
{/foreach}


Note that this is totally off the top of my head -- but if you look at issue.tpl, as well as other areas that present any links to articles (the keywordCloud plugin would be another example), you should get the idea. Let us know how it goes!

Cheers,
James
jmacgreg
 
Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest