I'm not sure if maybe we're looking in 2 different modules or what. I have a youtubeservice folder & in the code folder I have YoutubeGallery.php, YoutubeService.php, YoutubeWidget.php.
I've looked at all of them & YoutubeGallery.php is the one it's using. I've tried all the variables in there & get nothing. So I'm stumped.
I tried <% control YoutubeVideos %> but still can't get it to work. Here's the code from YoutubeGallery.php.
<?php
class YoutubeGallery extends Page {
// define your database fields here - for example we have author
static $db = array(
"Method" => "Int",
"User" => "Varchar",
"Query" => "Varchar",
"CategoryTag" => "Varchar",
"Playlist" => "Varchar",
"PerPage" => "Int",
"Sortby" => "Varchar"
);
static $defaults = array(
"Method" => 1,
"PerPage" => 10,
"Sortby" => 'relevance'
);
static $icon = "youtubeservice/images/youtube";
// add custom fields for this youtube gallery page
function getCMSFields($cms) {
Requirements::javascript( 'youtubeservice/javascript/YoutubeGallery_CMS.js' );
$fields = parent::getCMSFields($cms);
$fields->addFieldToTab("Root.Content.Videos", new DropdownField("Method", "Select ", array(
'1' => 'Videos containing phrase',
'2' => 'Videos by Category or Tag',
'3' => 'Videos uploaded by',
'4' => 'Favorite videos of',
'5' => 'Videos from playlist')));
$fields->addFieldToTab("Root.Content.Videos", new TextField("User","Youtube Username"));
$fields->addFieldToTab("Root.Content.Videos", new TextField("Query","Search for"));
$fields->addFieldToTab("Root.Content.Videos", new TextField("CategoryTag", "Category or Tag"));
$fields->addFieldToTab("Root.Content.Videos", new TextField("Playlist", "Playlist ID"));
$fields->addFieldToTab("Root.Content.Videos", new NumericField("MaxResults", "Per Page", 10));
$fields->addFieldToTab("Root.Content.Videos", new DropdownField("Sortby", "Sort by (descending)", array(
'relevance' => 'Relevance',
'updated' => 'Most Recent',
'viewCount' => 'Most Viewed',
'rating' => 'Most Rated')));
return $fields;
}
function YoutubeVideos(){
$youtube = new YoutubeService();
$page = isset($_GET['page'])? $_GET['page']: 1;
$start_index = (($page-1) * $this->PerPage) + 1 ;
switch ($this->Method){
case 1:
$videos = $youtube->getVideosByQuery($this->Query, $this->PerPage, $start_index, $this->Sortby);
break;
case 2:
$videos = $youtube->getVideosByCategoryTag($this->CategoryTag, $this->PerPage, $start_index, $this->Sortby);
break;
case 3:
$videos = $youtube->getVideosUploadedByUser($this->User, $this->PerPage, $start_index, $this->Sortby);
break;
case 4:
$videos = $youtube->getFavoriteVideosByUser($this->User, $this->PerPage, $start_index, $this->Sortby);
break;
case 5:
$videos = $youtube->getPlaylist($this->Playlist, $this->PerPage, $start_index, $this->Sortby);
break;
}
$outputHTML = "<div class='mainVideoContainer'><ul class='youtubevideos'>";
foreach($videos as $video){
$duration = round((float)$video->content_duration/60, 2);
$video->player_url = str_replace("watch?v=","/v/",$video->player_url);
$outputHTML .= '<div class="videoItem"><object width="425" height="344"><param name="movie" value="'.$video->player_url.'"></param><param name="allowFullScreen" value="true"></param><embed src="'.$video->player_url.'" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object><div class="info"><h6>'.$video->title.'</h6><p>'.$video->description.'<br/><strong>Duration : </strong>'.$duration.'</p></div></div>';
//$outputHTML .= '<li><div class="still"><a href="'.$video->player_url.'" title="'.htmlentities($video->title).'"><img src="'.$video->thumbnail_url.'" alt="'.htmlentities($video->title).'"/></a></div><div class="info"><h6><a href="'.$video->player_url.'" title="'.htmlentities($video->title).'">'.$video->title.'</a></h6><p>'.$video->description.'<br/><strong>Duration : </strong>'.$duration.'</p></div></li>';
}
$outputHTML .= "</ul></div>";
if($videos){
$outputHTML .= "<div class='pages'><div class='paginator'>";
$outputHTML .= $youtube->getPages();
$outputHTML .= "</div><span class='results'>(".$youtube->getTotalVideos()." Videos)</span></div>";
}
else {
$outputHTML .= "<span>Sorry! Gallery doesn't contain any images for this page.</span>";
}
return $outputHTML;
}
}
class YoutubeGallery_Controller extends Page_Controller {
function init() {
if(Director::fileExists(project() . "/css/YoutubeGallery.css")) {
Requirements::css(project() . "/css/YoutubeGallery.css");
}else{
Requirements::css("youtubeservice/css/YoutubeGallery.css");
}
parent::init();
}
function Content(){
return $this->Content.$this->YoutubeVideos();
}
}
?>