Embedding Gallery2.1 in My Own Page

zedlander
zedlander's picture

Joined: 2005-11-27
Posts: 28
Posted: Thu, 2006-02-02 19:59

Hello,
I want to be able to display image blocks in my main website's page, and I couldn't get the @readfile method to work. I found the workaround for Embedding Gallery.
The page where I want to have the Imageblocks is http://www.trevorcreech.com/testpage.php.
My gallery install is at http://photos.trevorcreech.com.
So, I have this code:

Quote:
<?php
/* You'll have to change the /gallery2/ thing in the following 2 lines probably */
require_once(dirname(__FILE__) . '/photos/embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true, 'baseUri' => 'http://www.trevorcreech.com/testpage.php', 'g2Uri' => 'http://photos.trevorcreech.com/'));
if ($ret) {
print 'GalleryEmbed::init failed, here is the error message: ' . $ret->getAsHtml();
exit;
}
/*
* See "Site admin" -> "image block" for all available options. the parameters are the same
* as for the external imageblock
*/
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage',
'show' => 'title|date'));
if ($ret) {
print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml();
exit;
}
/* $bodyHtml contains the image block. print it somewhere on your website */
print $bodyHtml;
/*
* $headHtml is not required. if you use imageframes for your imageblocks, you need to print
* $headHtml in the <head> section of your web page
*/
?>

I get no code returned...any idea what I'm doing wrong, or is there a better method?

Thanks.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2006-02-03 10:04

the answer is on your own homepage:

Quote:
I only want friends looking at my photos, so if you want the password, and I know you, pop off an email to Email Me, and I'll send it to you.

guests visitors don't have the permission to see any image, thus the imageblock returns nothing.

whatyou could do:
in site admin -> general, change the cookie settings to:
cookie domain: .trevorcreech.com
cookie path: /

then clear your browser cookie cache and login in g2 again.

drawback: visitors of yout site that haven't logged in to g2 yet won't see a random image on the other page.