Monday, June 29, 2009

Re: Sitepoint tutorial with Flickr component

Hey Hols,

Can you please checked  printing that $photo array??
Please check that one. If that array is blank / or please check the structure of that array then it gives the error.

On Mon, Jun 29, 2009 at 6:22 PM, Hols Kay <hollsk@googlemail.com> wrote:

Hi guys,

Quite new to this - I'm doing this tutorial:
http://www.sitepoint.com/article/photo-gallery-cakephp-flickr/ and I'm
having issues on index.ctp. This is the troublesome code:
-----------------------------------------------------------------
<img id="mainimg" src="<?php echo $flickr->buildPhotoURL($thumbs
['photo'][0], 'medium')?>" title="<?php echo $thumbs['photo'][0]
['title']?>"  alt="<?php echo $thumbs['photo'][0]['title']?>" />
-----------------------------------------------------------------

and this is the output I'm getting from it:
----------------------------------------------------------------
Notice (8): Undefined index: photo [APP\views\gallery\index.ctp, line
12] http://farm.static.flickr.com//_.jpg" title="" alt="" />
----------------------------------------------------------------

buildPhotoURL() looks like this:
----------------------------------------------------------------
       function buildPhotoURL ($photo, $size = "Medium") {
               //receives an array (can use the individual photo data returned
               //from an API call) and returns a URL (doesn't mean that the
               //file size exists)
               $sizes = array(
                       "square" => "_s",
                       "thumbnail" => "_t",
                       "small" => "_m",
                       "medium" => "",
                       "large" => "_b",
                       "original" => "_o"
               );

               $size = strtolower($size);
               if (!array_key_exists($size, $sizes)) {
                       $size = "medium";
               }

               if ($size == "original") {
                       $url = "http://farm" . $photo['farm'] . ".static.flickr.com/" .
$photo['server'] . "/" . $photo['id'] . "_" . $photo
['originalsecret'] . "_o" . "." . $photo['originalformat'];
               } else {
                       $url = "http://farm" . $photo['farm'] . ".static.flickr.com/" .
$photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes
[$size] . ".jpg";
               }
               return $url;
       }
----------------------------------------------------------------

I know the tutorial is quite out-of-date now, so something might have
changed in either API that I don't know about it, or I could just be
doing something wrong. Does anybody have any ideas, am I missing
something obvious?

Thanks!





--
Thanks & Regards,
Vijayk.
Co-founder (www.weboniselab.com)

"You Bring the Dreams, We'll Bring the Means"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: