Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Widgets /

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Flickr Widget


Go to End


6 Posts   3131 Views

Avatar
mhull

Community Member, 79 Posts

8 August 2009 at 10:42pm

I am having trouble getting the Flickr widget to work, I have the Flickr module up and working, but the Flickr widget isn't showing in the blog module widgets section. Does anyone have this working? anyone have any advice?

Avatar
joshy

Community Member, 57 Posts

9 August 2009 at 5:41am

Hiya,

Do you have other widgets working?
Have you selected the widget to appear in the Blog?
Are you calling $WidgetArea or whatever you have associated?

Josh

Avatar
mhull

Community Member, 79 Posts

9 August 2009 at 6:02am

I have the youtube widget working, and the other standard ones that come with the blog. The Flickr one just isn't showing up in the admin screen under blog>widget at all.

Anyone have this working? Or can anyone pinpoint why this isnt working for me?

Avatar
mhull

Community Member, 79 Posts

9 August 2009 at 8:08am

Edited: 09/08/2009 9:46am

Anyone got any ideas?
This just doesn't seem to be working for me. Not showing up in the widget tab at all

Avatar
mhull

Community Member, 79 Posts

12 August 2009 at 2:18am

I have now tried a new install of the Blog module, the Flickr module, and a fresh install of Silverstripe, and still the Flickr widget isnt showing up in the Blog window.

I have also tried making it a seperate widget in the root install, tried adding it into the Blog, and still it isn't working. Does anyone have it working?

Avatar
mhull

Community Member, 79 Posts

13 August 2009 at 4:48am

So I finally think I have found the answer to getting the Flickr Widget working, and I will post it here just in case anyone else has the same problem.

I was looking over the Widget Documentation at: http://doc.silverstripe.org/doku.php?id=widgets

Which uses the Flickr Widget as an example, by pasting in this code instead of the one that comes with the Module, I managed to get it working. However, I did have to put back in some of the code from the module, as it was referencing the wrong files for the lightwindow.

See the code below for the working Flickr Widget.

FlickrWidget.php

<?php
 
class FlickrWidget extends Widget {
	static $db = array(
		"User" => "Varchar",
		"Photoset" => "Varchar",
		"Tags" => "Varchar",
		"NumberToShow" => "Int"
	);
	
 
	static $defaults = array(
		"NumberToShow" => 8
	);
	
 
	static $title = "Photos";
	static $cmsTitle = "Flickr Photos";
	static $description = "Shows flickr photos.";
	
	function Photos() {
		Requirements::javascript("flickrservice/javascript/prototype.js");
	  	Requirements::javascript("flickrservice/javascript/effects.js");
	  	Requirements::javascript("flickrservice/javascript/lightwindow.js");
	  	
	  	Requirements::css("flickrservice/css/FlickrGallery.css");
		Requirements::css("flickrservice/css/lightwindow.css");
      
      	if( $pos = strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) {
      		$version = substr( $_SERVER['HTTP_USER_AGENT'], $pos + 5, 3 );
      		if( $version < 7 ) {
					Requirements::css("flickrservice/css/lightwindowIE6.css");
      		}
      	}
		
		$flickr = new FlickrService();
		if($this->Photoset == "") {
			$photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, 1);
		} else {
			$photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, 1);
		}
		
		$output = new DataObjectSet();
		foreach($photos->PhotoItems as $photo) {
			$output->push(new ArrayData(array(
				"Title" => $photo->title,
				"Link" => "http://farm1.static.flickr.com/" . $photo->image_path .".jpg",
				"Image" => "http://farm1.static.flickr.com/" .$photo->image_path. "_s.jpg"
			)));
		}
		
		return $output;
	}
 
	function getCMSFields() {
		return new FieldSet(
			new TextField("User", "User"),
			new TextField("PhotoSet", "Photo Set"),
			new TextField("Tags", "Tags"),
			new NumericField("NumberToShow", "Number to Show")
		);
	}
}
 
?>