How to pass data to Templates

This question is to @NateWr.
Nate,
James may have informed you that we’re looking for helping ordering the display of articles on the front page. I followed the instructions as best as I can but I’m stuck.

If you’d like, here is my custom theme

I think I’ve set everything up correctly and I’ve passed the articles data to the template. My question is, can you point me to the documentation on PublishedArticleDAO so I know how to display the info I’ve given the template?

Thanks
Kane

Hi Kane,

So once you’ve done this:

$articles =& $publishedArticleDao->getPublishedArticlesByJournalId($journalId = null, $rangeInfo = null, $reverse = false);
$templateMgr->assign('articles', $articles->toArray());

The template should now have an {$articles} variable that is an array of PublishedArticle objects. You can see some of the methods available here:

https://github.com/pkp/ojs/blob/master/classes/article/PublishedArticle.inc.php

That class extends Article, so you’ll find more methods here:

https://github.com/pkp/ojs/blob/master/classes/article/Article.inc.php

And that class extends Submission so you’ll find more methods here:

https://github.com/pkp/pkp-lib/blob/master/classes/submission/Submission.inc.php

And that class extends DataObject, so you’ll find more methods here:

So all of those methods are available to you to display information about the articles. In your template, I’d probably do something like this:

{if count($articles)}
  <h2>Latest Articles</h2>
  <ul class="articles">
    {foreach from=$articles item="article"}
      <li>
        {include file="frontend/objects/article_summary.tpl"}
      </li>
    {/foreach}
  </ul>
{/if}

That will low pass each article to the article_summary.tpl template. But you can also write a custom template just for the homepage and use that instead.

Thanks @NateWr. This is exactly what I needed