public function listAction() { $limit = 10; //查询数据 $genre = new \Genre(); $list = $genre->getList(); //数据 $page_html = $this->pageHtml($list); //分页html $this->view->setVars(['list' => $list, 'page_html' => $page_html]); }
// genre/1/artist - list of artists for genre=1 // page head=genre.name, list head=null // // genre/1/artist/2/album - list of albums for genre=1, artist=2 // page head=artist.artist, list head=null // // genre/1/artist/2/album/3/song - list of songs for genre=1, artist=2, album=3 // page head=artist.artist, list head=album+stats // // // genre/1/artist/2/album/3/song/4 - load all songs for genre=1, artist=2, album=3, play song=4, go to nowplaying // genre - list all genres // $klein->respond('GET', '/genre', function ($request, $response) { // get the list of albums $list = Genre::getList(); // walk the array and construct URLs // The encoded URL value is actually "artist name|album title". The artist // name is included to ensure that albums with the same name are not // conflated and the pipe character is a delimiter array_walk($list, function (&$v, $k) { $v = array('name' => $v, 'url' => '/genre/' . Music::encode($v) . '/artist'); }); return ListPage::render('Genres', null, false, false, $list); }); // genre/1/artist - list of artists for genre=1 // $klein->respond('GET', '/genre/[:genre]/artist', function ($request, $response) { // get the parameter $genre = Music::decode($request->param('genre')); // get the list