OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



supplementary files links

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

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

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

supplementary files links

Postby Rames » Mon Aug 25, 2008 2:32 pm

I'd like to add links to an article's supplementary files from the current issue page. Essentially, I want to implement code from suppFiles.tpl in issue.tpl, but am not sure as to the best way to go about this. I assume I need to access the getSuppFiles() function from issue.tpl. Any tips on how to go about this would be most helpful. I'm using OJS v2.2.

I'd also like to display the number of comment received by and article from issue tpl. I can do so using {$comments|@count} in comments.tpl but could use some pointers on how to access each article's populated $comments variable from issue.tpl.

Thanks in advance,

rames
Rames
 
Posts: 13
Joined: Mon Mar 24, 2008 1:02 pm

Re: supplementary files links

Postby mcrider » Mon Aug 25, 2008 7:19 pm

Hi Rames,

To do this, you'll have to assign variables to issue.tpl via pages/issue/IssueHandler.inc.php, in the setupIssueTemplate function.. From there, you can assign getSuppFiles() to a variable, and in the template, use a foreach to iterate over the variable and perform whatever operations you need to on that SuppFile object. Similarly, you can reference the article's comments by assigning a template variable in this function (you'll probably have to instantiate a articleCommentDao object and reference that). Let us know if you run into any problems!

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: supplementary files links

Postby Rames » Tue Aug 26, 2008 11:08 am

Hi Matt,

Thanks for the quick reply. I've made a few modifications to the OJS code in the past, but this one is eluding me. Could you give me an example of code I need to add to IssueHandler.inc.php?

rames
Rames
 
Posts: 13
Joined: Mon Mar 24, 2008 1:02 pm

Re: supplementary files links

Postby mcrider » Tue Aug 26, 2008 4:26 pm

Hi again Rames,

This one eluded me for a while too--Upon further inspection, it seemed to me that putting in the code from templates/rt/suppFiles.tpl (i.e. all the code in between the foreach tags) into templates/issue/issue.tpl should work (without having to modify issueHandler.inc.php). As you probably also found, it doesn't--Until you change lines 75 and 201 in issueHandler.inc.php from
Code: Select all
$publishedArticles = &$publishedArticleDao->getPublishedArticlesInSections($issue->getIssueId(), true);
to
Code: Select all
$publishedArticles = &$publishedArticleDao->getPublishedArticlesInSections($issue->getIssueId());

There may be a good reason why the getPublishedArticlesInSections() function fetches the 'simple' section object, but I suspect its just to save memory and you're safe making the mod.

As for the comments, unfortunately I think you'll still have to hack away at issueHandler.inc.php, since theres no way to just get an article's comments from the article object. One way to approach this is to make an array of arrays in IssueHandler, containing an article's ID and the count of how many comments it has, pass it to the template, then search the array from the template. Here's an example--I'm not sure how well it will work, and also it will only get the number of root comments (not any comments on comments).
Code: Select all
$commentDao = &DAORegistry::getDAO('CommentDAO');
$articleInfo = array();
$publishedArticlesTemp = &$publishedArticleDao->getPublishedArticles($issue->getIssueId(), null, true);   
foreach ($publishedArticlesTemp as $publishedArticle) {
   $commentSize = sizeof($commentDao->getRootCommentsByArticleId($publishedArticle->getArticleId()));
   array_push($articleInfo, array($publishedArticle->getArticleId(), $commentSize));
}
$templateMgr->assign_by_ref('articleInfo', $articleInfo);

You'll have to put it in both the setupIssueTemplate() and current() functions in IssueHandler. I'll leave you implement it in issue.tpl :)

Hope that helps,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: supplementary files links

Postby Rames » Wed Aug 27, 2008 3:12 pm

Hi Matt,

Excellent, your modifications work perfectly. I implemented the new variables on issue.tpl from current issues and the home page TOC. Kudos to the OJS support folks!

One minor thing is the code i dropped in from SuppFiles.tpl calls $galleyId in the 'Indexing Metada' link, which it does not appear issueHandler.inc.php includes in the issue object. But that's OK, i wasn't going to use those links anyway.

Thank you,

rames
Rames
 
Posts: 13
Joined: Mon Mar 24, 2008 1:02 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest