mysite/code/FlickrPage.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

class FlickrPage extends Page { }

class FlickrPage_Controller extends Page_Controller {

  function Photos() {
    require_once("../sapphire/thirdparty/simplepie/simplepie.inc");

    $this->feed = new SimplePie("path to a flickr feed url", "../silverstripe-cache/");
    $this->feed->init();

    $items = new DataObjectSet();

    if($this->feed->get_items()) {
      foreach ($this->feed->get_items() as $item) {
        $items->push(new ArrayData($item));
      }
    }

    return $items;
  }
}

FlickrPage.ss

1
2
3
4
<% control Photos %>
$Title
<% end_control %>