For my music database I have a CGridView with pagination of one. How can I load additional data which are not in data model and not in $dataProvider? For instance I will fetch album cover from LastFM. Here is the Controller function:
public function actionCover()
{
$artist = '';
$title = '';
if(isset($_GET['artist']))
$artist=$_GET['artist'];
if(isset($_GET['title']))
$title=$_GET['title'];
Yii::import('application.extensions.lastfmapi.lastfmApiAuth');
$authVars = array(
'apiKey' => '<my_LastFM_Api-Key'
);
$config = array(
'enabled' => true,
'path' => '../media/lastfmapi/',
'cache_length' => 1800
);
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$albumClass = $apiClass->getPackage($auth, 'album', $config);
// Setup the variables
$methodVars = array(
'artist' => $artist,
'album' => $title
);
if ($album = $albumClass->getInfo($methodVars) ) {
echo '<img src='.$album["image"]["large"].'>';
}
else {
die('<b>Error '.$albumClass->error['code'].' - </b><i>'.$albumClass->error['desc'].'</i>');
}
return();
}
My idea was a ajax call in CGridView for a virtual column in album model.