3

I have figured out how to add data from a model into a grid like the examples on the learning section of the Agile Toolkit website. But I'm looking for the correct way to show data from a database without a grid.

Say I have a news database and I want to display it as a blog style news on my home page. Can someone point me to where to begin?

Trying to make this a little more clear: I want to display data from multiple columns from a table news. So I would need to know how to get the title, date, author, content and then repeat that for say 5 latest news articles.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Losey
  • 137
  • 7

1 Answers1

3

try this:

$this->add('View',null,null,array('view/mytemplate'))
    ->setModel('MyModel')
    ->loadData(123);

then inside templates/defaults/view/mytemplate.html

<div><h2><?$title?></h2>
   <p><?$content?></p>
</div>

You can also use it with any view, even page.

$data=$model->get();
$page->template->set($data);

you can re-define template for your page by defining defaultTemplate function

function defaultTemplate(){
    return array('page/mypage');
}
romaninsh
  • 10,606
  • 4
  • 50
  • 70