I would like to include the latest two items published in the journal’s homepage. I know that a similar question has been asked before but mine does not have the complication of a feed from multiple Journals in to the main homepage…
We only have one Journal and I want the latest two items in this Journal’s homepage.
More precisely I want exactly what I see when I go to the current issue’s page (issue.tpl) but not taxonomised in sections; simply the latest two, regardless of the section (we have different article sections in our journal).
I started by copying the /templates/issue/issue.tpl to a new file (issue2.tpl), so I do not change the structure of the Current Issue page and then edited the /templates/index/journal.tpl file at the bottom to include my new file ({include file=“issue/issue2.tpl”}) instead of {include file=“issue/view.tpl”}.
The idea works great except I cannot modify the code to show me only the latest two articles, regardless of the sections; I am getting the full section-taxonomised list as in the Current Issue TOC…
I am fairly certain that there should be a simple code for that.
I would greatly appreciate any help on this. I am trying to go live on Monday…
Have a look at the PublishedArticleDAO’s getPublishedArticlesByJournalId function. This should allow you to get the most recent N articles, regardless of issue.
Regards,
Alec Smecher
Public Knowledge Project Team
thank you so much for coming back to me, and it sounds that this is the right direction… I tried a few things but I am a bit out of my depth… Is it possible to give me more detailed help/instructions. Really sorry to impose on your time but I have a feeling this may benefit a lot of people who would like to use it.
There’s an example of the use of this function here:
I can’t guide through the modification in detail, but generally speaking, you’ll need to edit pages/index/IndexHandler.inc.php (which handles requests for the homepage) to assign the results of PublishedArticleDao::getPublishedArticlesByJournalId to the template manager. That’ll make it available from within the template file.
If you’re getting stuck somewhere specific, feel free to write it up.
Regards,
Alec Smecher
Public Knowledge Project Team