Jump to:

791 Posts in 369 Topics by 303 members

Widgets

SilverStripe Forums » Widgets » Flickr Widget

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1946 Views
  • mhull
    Avatar
    Community Member
    79 Posts

    Flickr Widget Link to this post

    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?

  • joshy
    Avatar
    Community Member
    57 Posts

    Re: Flickr Widget Link to this post

    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

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Flickr Widget Link to this post

    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?

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Flickr Widget Link to this post

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

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Flickr Widget Link to this post

    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?

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Flickr Widget Link to this post

    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")
          );
       }
    }

    ?>

    1946 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.