Hi,
I'm a bit of a beginner with php, so not sure how to work round this issue.
I was successfully using the random image php block from my gallery in another php page.
However my ISP has just turned off URL-style fopen support.
For example, say my current random image block call is as follows:
<? readfile('http://[mydomain]/gallery/main.php?g2_view=imageblock:External&g2_blocks=randomImage');
?>
If I change this to use a relative path, php seems to fail to find the main.php script due to the parameters after the question mark.
Can anybody provide me with a workaround for this issue, as I found the random block/new album feature very nice.
Hopefully I've explained this clearly enough.
Thanks in advance,
Conor Boyd
Posts: 32509
you'll have to use the GalleryEmbed API, something like:
include('path/to/gallery2/embed.php');
$ret = GalleryEmbed::init(array('embedUri' => , 'embedPath' => , 'relativeG2Path' => ));
if ($ret->isError()) {
print $ret->getAsHtml();
exit;
}
list ($ret, $html, ...) = GalleryEmbed::getImageBlock(array(....));
if ($ret->isError()) {
print $ret->getAsHtml();
exit;
}
print $html;
etc.
see docs/EMBEDDING for correct values for embedUri, embedPath, relativeG2Path.
getImageBlock() accepts the same arguments as imageblock:External, see modules/core/classes/GalleryEmbed.class for more information.
Posts: 166
Thanks Valiant,
I've give that a go when I have a spare minute.
Sounds perfect.
Cheers,
Conor
Posts: 166
I've worked through the example above and looked at the EMBEDDING doc and the class (BTW, I'm on G2 Beta 3).
My test script seems to be initializing Gallery okay, but I get the following error when I call the getImageBlock method as follows:
gives me this:
Have I done something stupid? Easy fix? ;-)
Thanks again for any help...
Cheers,
Conor
Posts: 32509
you have to use GalleryEmbed::init(array(..., 'fullInit' => true));
sorry, forgot about that.
and it may be a good idea to use g2 beta 3+ aka the current nightly snapshot from http://galleryupdates.jpmullan.com
Posts: 166
Spot on.
That's brilliant Valiant, thanks very much!
I'll check out the latest snapshot.
Cheers,
Conor