I've noticed that using the url descriptors for embedding into an external page (in my case phpnuke) do not work.
Following the external image block notes on the Image Block Admin within Random/Popular Block of Site Admin states that the following url should be used:
<?php @readfile('http://www.mydomain.com/modules.php?name=gallery2&g2_view=imageblock:External&g2_blocks=randomImage&g2_show=title'); ?>
However using this within a html page inside Nuke displays the entire site module within a site, as opposed to just the photo.
This was never an issue using random block in gallery 1.x.
Using the non embedded link; work's effectively but the link to the photo displayed obviously shows gallery in non-embedded form when clicked.
<?php @readfile('http://www.mydomain.com.com/modules/gallery2/main.php?g2_view=imageblock:External&g2_blocks=randomImage&g2_show=title'); ?>
Any ideas how we can fix this?
Posts: 32509
plop1, interesting what you try there.
modules.php?name=gallery2 calls your wrapper file. your wrapper file gets the html from G2 and puts it into the phpnuke site.
what you want: if it's an external imageblock request, your wrapper should just return the html that is returned from g2, and not put it into the phpnuke page.
your options:
a) change your wrapper file. after GalleryEmbed::handleRequest(), check if GalleryUtilities::getRequestVariable('g2_view') or just 'view' don't remember, is equal to imageblock:External (or imageblock.External as mindless just changed : to .).
if so, then return the g2 html instead of putting into the phpnuke page (i.e. echo bodyHtml; exit; would do the job).
b) instead of readfile(url), you could use GalleryEmbed::init(); GalleryEmbed::getImageBlock();
GalleryEmbed::done();
c) extend the imageblock:external controler to accept an url parameter, then call main.php with the correct parameters.
Posts: 16
Great,
so If I opt for option b; it should look like this (although it doesn't work as yet) where:
where the following embedded code: is at url http://www.mydomain.com/modules.php?name=genealogy (wrapper to /modules/genealogy/index.html)
gallery2 is at /modules/gallery2
require_once("http://www.mydomain.com/modules/gallery2/embed.php");
$ret = GalleryEmbed::init(array('embedUri' => 'http://www.mydomain.com/modules.php?name=gallery2', 'embedPath' => '/', 'relativeG2Path' => '../gallery2', 'loginRedirect' => '', 'activeUserId' => null));
list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'title'));
GalleryEmbed::done();
Any ideas on what I'm doing wrong?
Posts: 430
i think activeUserId may not be "null", do you get any errors?
Posts: 16
Solved it!
replace @readfile statement with:
<?
require_once("modules/gallery2/embed.php");
$ret = GalleryEmbed::init(array('embedUri' => 'http://www.mydomain.com/modules.php?name=gallery2', 'embedPath' => '/', 'relativeG2Path' => 'modules/gallery2', 'loginRedirect' => '', 'activeUserId' => null));
list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'title'));
echo "$imageBlockHtml";
GalleryEmbed::done();
?>
Posts: 4
I didnt want to do a full Embedded plugin deal, all I wanted was the randomImage block on my main page. g2 has a nice little one-liner using readfile() that I could have used... EXCEPT .. Im running my site allow_url_fopen = false, which effectly disables that readfile() approach.
In order to get my site to work, I had to replace that one-liner with the block of code below.
my /gallery2/ installation is called /photos/ and this code snippet lives in the page that servers as my main index.php page.
And yes, I read the docs at
http://gallery.menalto.com/modules/GalleryAPI/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodinit
but, the formatting for the parameter list is hideous.
I needed to use 'fullInit' => false in order for it to work at all as a replacement for the "drop in randomImage", even tho the docs make it sound like an optional param. I also dropped some parameters that were NOT marked as optional and it still works, so Im not entirely sure what to believe anymore
-tak
Posts: 32509
mtakacs,
oops: just checked the code: we only check for isset($params['fullInit']) and not for $params['fullInit'] == true.
committed the fix to the cvs. get the next nightly to get this change.
so, translating your fullInit = false to the new, corrected code is equal to fullInit = true.
And yes, fullInit is required for the imageblock. right.
plop1, michiel is right, don't set 'activeUserId' => null, set it to 'activeUserId' => '' (empty string).
Posts: 430
Strange i tried 'activeUserId' => '' (for quest users)
i got this error:
Input Array does not match ?: SELECT DISTINCT gallery_AccessMap.g_accessListId FROM gallery_AccessMap WHERE (gallery_AccessMap.g_userId = NULL OR gallery_AccessMap.g_groupId IN (1)) AND gallery_AccessMap.g_permission & 1 =
Posts: 32509
michiel_1981, this slightly reminds of someone having the same error, but in standalone.
what G2 version are you using?
could you clear all your GALLERYSID cookies in your browser and test if you can browse around as a guest/anonymous user in standalone G2.
then try again this embedded code, with activeUserId => ''.
Posts: 430
hehe what clearing cookies can do. It worked.
do you still like to know which version? i think cvs between 18-20 may
0.9.18
2.0-beta-3+
Posts: 32509
michiel_1981, good
Posts: 32509
ozgreg pointed out that fullInit is not needed for getimageblock. and he's right.
you can ommit fullInit in the init call or set it to true for getImageBlock.
Posts: 32509
Sorry, got to revert that statement.
See: http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&p=142795#142795
fullInit true is needed for getImageBlock().
Posts: 16
All was well; however I've just noticed that a first time visitor to the site gets this error:
Input Array does not match ?: SELECT DISTINCT g2_AccessMap.g_accessListId FROM g2_AccessMap WHERE (g2_AccessMap.g_userId = NULL OR g2_AccessMap.g_groupId IN (1)) AND g2_AccessMap.g_permission & 1 =
from
Tried, null '' & guest. Any ideas? (if user goes in and out of gallery2 the error goes away)[/]
Posts: 16
doh.. just reread the use of fullinit code now;