How to pass data to Templates

This question is to @NateWr.
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?


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:

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

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

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"}
        {include file="frontend/objects/article_summary.tpl"}

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