// conflated and the pipe character is a delimiter array_walk($list, function (&$v, $k) use($genre) { $v = array('name' => $v['artist'], 'url' => '/genre/' . Music::encode($genre) . '/artist/' . Music::encode($v['artist']) . '/album'); }); // build the "previous" link data $previous = array('path' => '/genre', 'text' => 'Genres'); return ListPage::render($genre, $previous, false, false, $list); }); // genre/1/artist/2/album - list of albums for genre=1, artist=2 // $klein->respond('GET', '/genre/[:genre]/artist/[:artist]/album', function ($request, $response) { // get the parameter $genre = Music::decode($request->param('genre')); $artist = Music::decode($request->param('artist')); // get the list $list = Genre::getAlbums($genre, $artist); // 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) use($genre) { $v = array('name' => $v['album'], 'url' => '/genre/' . Music::encode($genre) . '/artist/' . Music::encode($v['artist']) . '/album/' . Music::encode($v['album']) . '/song'); }); // build the "all songs" link $allsongs = '/genre/' . Music::encode($genre) . '/artist/' . Music::encode($artist) . '/song'; // build the "previous" link data $previous = array('path' => '/genre/' . $request->param('genre') . '/artist', 'text' => 'Artists'); return ListPage::render($artist, $previous, false, $allsongs, $list); }); // genre/1/artist/2/album/3/song - list of songs for genre=1, artist=2, album=3 //