开发者

How do you display info from a database

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 d开发者_Python百科ata 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.


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');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜