Reputation: 555
Ok I just started kostache and I would like to display the results i got from the database using orm in kohana 3.3. I know how to display them using foreach statement but when using kostache it's way different. So here's my code.
APPATH/classes/controller/album.php
class Controller_Album extends Controller
{
public function action_index()
{
$view = Kostache_Layout::factory();
$this->response->body($view->render(new View_Pages_Album_List));
}
}
APPATH/classes/view/pages/album/list.php
class View_Pages_Album_List {
public $title = 'List of Music';
public function album_list()
{
$albums = ORM::factory('Album_Information')->find_all();
return $albums;
}
}
APPATH/templates/pages/album/list.mustache
{{album_list}}
How would i display the resulst?. How would you do this in kostache?
Thanks and more power.
Upvotes: 0
Views: 76
Reputation: 555
Well Nevermind I got it working..
public function album_list()
{
$albums = ORM::factory('Album_Information')->find_all();
$album_info = array();
foreach ($albums as $a)
{
$album = array('album' => array('artist' => $a->Artist, 'album_name' => $a->Album_Name,));
$album_info[] = $album;
}
return $album_info;
}
Upvotes: 1