简体   繁体   中英

display results in kostache

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.

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;

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM