Author Topic: slideshow MOD that uses the Google AJAX RSS Slideshow API  (Read 10137 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris4A

  • Pre-Newbie
  • Posts: 2
    • View Profile
slideshow MOD that uses the Google AJAX RSS Slideshow API
« on: February 18, 2008, 04:38:17 AM »
This is a slideshow MOD that uses the Google AJAX RSS Slideshow API.

It can display JPEG and PNG pictures, and is customizable. The Google AJAX RSS Slideshow API is described here, and there are examples of what the slideshow looks like in action:
http://www.google.com/uds/solutions/slideshow/index.html

To use this Google API, this mod changes/adds to 4images the ability to produce a Media RSS 2.0 compliant RSS feed, in addition to the regular new pictures RSS feed that it already produces. This feed is used for the Google Slideshow API, but could be used standalone.

As a technical detail, this MOD uses the slideshow API slightly differently, in that it doesn't depend on your site having thumbnails for your pictures - it feeds the slideshow the actual pictures themselves.

IMPORTANT: To be able to use this MOD, you have to get your own Google API key. It's free and simple, but you have to get one and put it in the new file sshow.php linked below.

Hope this is useful to people!
Chris Andrichak


changed files:
rss.php
categories.php
templates/default/categories.html

new files:
sshow.php remember to get the Google API key
templates/default/mrss.xml
templates/default/mrss_item.xml
--> download zip


rss.php
insert after:
Code: [Select]
$main_template = 'rss';
this code
Code: [Select]
$sub_template = "rss_item";
$media_template = 'mrss';
$media_sub_template = "mrss_item";

change:
Code: [Select]
@define('RSS_MAX_ITEMS', 30);
to
Code: [Select]
@define('RSS_MAX_ITEMS', 100);

change:
Code: [Select]
if (isset($HTTP_GET_VARS['items']) || isset($HTTP_POST_VARS['items'])) {
to
Code: [Select]
// # of images in category is passed in over HTTP Get (increased max limit to accomodate
// larger category total sets
if (isset($HTTP_GET_VARS['slc']) || isset($HTTP_POST_VARS['items'])) {
  $num_items = (isset($HTTP_POST_VARS['items'])) ? intval($HTTP_POST_VARS['items']) : intval($HTTP_GET_VARS['slc']);

insert after:
Code: [Select]
  $action = 'images';
this code
Code: [Select]
} else if ($action == 'media') {
  // use media RSS template
  $main_template = $media_template;
  $sub_template = $media_sub_template;

insert after:
Code: [Select]
  case 'images':
this code
Code: [Select]
  case 'media':

insert before:
Code: [Select]
        'author' => array(
this code
Code: [Select]
        'enclosure_info' => ($row['image_thumb_file'] ? getimagesize(THUMB_PATH."/".$row['cat_id']."/".$row['image_thumb_file']) : array(0,0, "", "")),
        'realimage' => get_rss_enclosure($row['image_media_file'], "media", $row['cat_id']),
        'realimage_info' => getimagesize(MEDIA_PATH."/".$row['cat_id']."/".$row['image_media_file']),

insert after:
Code: [Select]
    'item_enclosure_type' => '',
this code
Code: [Select]
    'item_enclosure_width' => '',
    'item_enclosure_height' => '',
    'item_enclosure_info_width' => '',
    'item_enclosure_info_height' => '',
    'item_realimage' => false,
    'item_realimage_url' => '',
    'item_realimage_length' => '',
    'item_realimage_type' => '',
    'item_realimage_width' => '',
    'item_realimage_height' => '',
    'item_realimage_info_width' => '',
    'item_realimage_info_height' => '',

insert after:
Code: [Select]
    $tpl_vars['item_enclosure'] = true;
this code
Code: [Select]
// set thumbnail height/width
    $tpl_vars['item_enclosure_width'] = $item['enclosure_info'][0];
    $tpl_vars['item_enclosure_height'] = $item['enclosure_info'][1];
// have to %20 encode the URIs for RSS (the file path is probably ok, but what about other %s?
    $tpl_vars['item_enclosure_url'] = str_replace(" ", "%20", $item['enclosure']['url']);


insert before:
Code: [Select]
  $site_template->register_vars($tpl_vars);
this code
Code: [Select]
  if ($action == 'media') {
  // only need this if we're in the media template
  if (@count($item['realimage']) > 0) {
$tpl_vars['item_realimage'] = true;
// set full image height/width
$tpl_vars['item_realimage_width'] = $item['realimage_info'][0];
$tpl_vars['item_realimage_height'] = $item['realimage_info'][1];

// have to %20 encode the URIs for RSS (the file path is probably ok, but what about other %s?
$tpl_vars['item_realimage_url'] = str_replace(" ", "%20", $item['realimage']['url']);
$tpl_vars['item_realimage_length'] = $item['realimage']['length'];
$tpl_vars['item_realimage_type'] = $item['realimage']['type'];
  }
  }

change:
Code: [Select]
  $items .= $site_template->parse_template("rss_item");
to
Code: [Select]
  $items .= $site_template->parse_template($sub_template);



categories.php
insert before:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
this code
Code: [Select]
//-----------------------------------------------------
//--- Slideshow ---------------------------------------
//-----------------------------------------------------
$mrss_url = $script_url."/rss.php?action=media&".URL_CAT_ID."=".$cat_id."&slc=".$num_rows_all;
$gslideshow_url = $script_url."/sshow.php?rssurl=".urlencode($mrss_url);
if ($num_rows_all > 0) {
$gslideshow = "<span class=\"slideshow\"><a href=\"#\" onClick=\"window.open('".$gslideshow_url."','_blank','toolbar=0, location=0, scrollbars=0, menuBar=0, width=500, height=520'); return(false)\">View Slideshow of Images</a></span>";
} else {
$gslideshow = "&nbsp;";
}

$site_template->register_vars(array(
  "gslideshow_url" => $gslideshow_url,
  "gslideshow"   => $gslideshow
));



categories.html
change:
Code: [Select]
  {paging_stats}
  <br />
  <br />
to
Code: [Select]
  <p>
  {gslideshow}
  </p>

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: slideshow MOD that uses the Google AJAX RSS Slideshow API
« Reply #1 on: February 18, 2008, 05:02:05 AM »
Purfect code structure. ;)

Two lines:

Code: [Select]
'enclosure_info' => ($row['image_thumb_file'] ? getimagesize(THUMB_PATH."/".$row['cat_id']."/".$row['image_thumb_file']) : array(0,0, "", "")),

for this:

Code: [Select]
'enclosure_info' => (isset($row['image_thumb_file']) && !empty($row['image_thumb_file'])) ? getimagesize(THUMB_PATH."/".$row['cat_id']."/".get_basefile(stripslashes(trim($row['image_thumb_file'])))) : array(0,0, "", "")),

This:

Code: [Select]
$site_template->register_vars(array(
  "gslideshow_url" => $gslideshow_url,
  "gslideshow"   => $gslideshow
));

for:

Code: [Select]
$site_template->register_vars(array(
  "gslideshow_url" => (isset($gslideshow_url) && !empty($gslideshow_url)) ? $gslideshow_url : "",
  "gslideshow"   => (isset($gslideshow) && !empty($gslideshow)) ? $gslideshow : ""
));

;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Chris4A

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: slideshow MOD that uses the Google AJAX RSS Slideshow API
« Reply #2 on: February 18, 2008, 05:18:22 AM »
I forgot to mention that this was developed at tested with 4images v1.7.4-1.7.6

Offline WVHeliClub

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: slideshow MOD that uses the Google AJAX RSS Slideshow API
« Reply #3 on: July 07, 2009, 05:11:54 AM »
Is there a way to update the rss feed to the "media rss 2.0" without the google ajax api included?


                                                                                                 thanks in advance

Offline GaYan

  • Sr. Member
  • ****
  • Posts: 301
  • ♫ | G2 | ♫
    • View Profile
    • Ziramagic
Re: slideshow MOD that uses the Google AJAX RSS Slideshow API
« Reply #4 on: July 07, 2009, 02:12:44 PM »
How can i see the Slide show ???  :oops:

i tired ... but only image names appearead... i need serious hel ove hre...

thanks

Gayan !
I'm Back :)