Get a Flickr Set into Drupal


/ Published in: PHP
Save to your folder(s)

This is a snippet I did for a project-- it relies on Drupal and the Flickr module for Drupal.


Copy this code and paste it in your HTML
  1. <?
  2.  
  3. $arg['per_page'] = 48;
  4. $arg['page'] = 1;
  5. $arg['tags'] = "E31"; // the default tag
  6.  
  7. ?>
  8. <ul>
  9. <li><a href="?tags=H32">January 2007 - H32</a>
  10. <li><a href="?tags=J31">February 2007 - J31</a>
  11. <li><a href="?tags=N27">March 2007 - N27</a>
  12. <li><a href="?tags=G30">April 2007 - G30</a>
  13. <li><a href="?tags=H22">May 2007 - H22</a>
  14. <li><a href="?tags=M29">June 2007 - M29</a>
  15. <li><a href="?tags=H28">July 2007 - H28</a>
  16. <li><a href="?tags=H31">August 2007 - H31</a>
  17. <li><a href="?tags=N29">September 2007 - N29</a>
  18. <li><a href="?tags=L31">October 2007 - L31</a>
  19. <li><a href="?tags=N24">November 2007 - N24</a>
  20. <li><a href="?tags=M31">December 2007 - M31</a>
  21. <li><a href="?tags=Q28">January 2008 - Q28</a>
  22. <li><a href="?tags=H24">February 2008 - H24</a>
  23. <li><a href="?tags=E31">March 2008 - E31</a>
  24. </ul>
  25.  
  26. <?
  27.  
  28. if ($_GET['page']) {
  29. $arg['page'] = intval($_GET['page']);
  30. }
  31. if (strlen($_GET['tags']) > 2) {
  32. $arg['tags'] = $_GET['tags'];
  33. drupal_set_title(t('Archives for '.$_GET['tags']));
  34. }
  35.  
  36. $response = false;
  37.  
  38. $arg['group_id'] = "92284808@N00"; // Victoria Grid Project group
  39.  
  40. $arg_hash = '';
  41. $args = '';
  42.  
  43. $set_response = flickr_request('flickr.groups.pools.getPhotos', $arg);
  44. $output = "";
  45.  
  46. $photos['page'] = $set_response['photos']['page'];
  47. $photos['pages'] = $set_response['photos']['pages'];
  48. $photos['perpage'] = $set_response['photos']['perpage'];
  49. $photos['total'] = $set_response['photos']['total'];
  50.  
  51. foreach ($set_response['photos']['photo'] as $result) {
  52.  
  53. $x++;
  54. $item['taken'][$x] = FALSE;
  55. $item['id'][$x] = $result['id'];
  56. $item['owner'][$x] = $result['owner'];
  57. $item['secret'][$x] = $result['secret'];
  58. $item['server'][$x] = $result['server'];
  59. $item['farm'][$x] = $result['farm'];
  60. $item['title'][$x] = $result['title'];
  61. $item['ispublic'][$x] = $result['ispublic'];
  62. $item['isfriend'][$x] = $result['isfriend'];
  63. $item['isfamily'][$x] = $result['isfamily'];
  64. $item['ownername'][$x] = $result['ownername'];
  65. $item['dateadded'][$x] = $result['dateadded'];
  66. }
  67.  
  68. $output .= '<table cellspacing="0" cellpadding="5" border="0">';
  69.  
  70. for ($y = 1; $y <= $x; $y++) {
  71. if ($item['taken'][$y] === FALSE) {
  72. $item['taken'][$y] = TRUE;
  73. if ((($y % 3) == 1) || ($y == 1)) {
  74. $output .= "<tr>";
  75. }
  76. $output .= '<td valign="top" align="center"><a href="http://farm'.$item['farm'][$y].'.static.flickr.com/'.$item['server'][$y].'/'.$item['id'][$y].'_'.$item['secret'][$y].'_b.jpg" rel="lightbox" title="'.$item['title'][$y].' by '.$item['ownername'][$y].'"><img src="http://farm'.$item['farm'][$y].'.static.flickr.com/'.$item['server'][$y].'/'.$item['id'][$y].'_'.$item['secret'][$y].'_m.jpg" width="160" alt="'.$item['title'][$y].' by '.$item['ownername'][$y].'"></a><br/><a href="http://www.flickr.com/photos/'.$item['owner'][$y].'/'.$item['id'][$y].'/in/pool-victoriagridproject" >'.$item['title'][$y].' by '.$item['ownername'][$y].'</a></td>';
  77. if ((($y % 3) == 0) || ($y == $x)) {
  78. $output .= "</tr>\n";
  79. }
  80. $maketr = 1;
  81. }
  82. }
  83.  
  84. $output .= "</table>";
  85.  
  86. $output .= "<center>";
  87. for ($a = 1; $a <= $photos['pages']; $a++) {
  88. if ($a != $photos['page']) {
  89. $output .= '<a href="?page='.$a.'&tags='.$arg['tags'].'">'.$a."</a> ";
  90. }
  91. else {
  92. $output .= '<b>'.$a."</b> ";
  93. }
  94. }
  95. $output .= '<br/>'.((($photos['page'] - 1) * $photos['perpage']) + 1).' - '.($photos['page'] * $photos['perpage']).' of '.$photos['total'].' photos';
  96. $output .= "</center>";
  97.  
  98. print $output;
  99. ?>

URL: http://www.crowdpublishing.com/vgp/archives

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.