[SOLVED] Random Block when Embedded
plop1
![]()
Joined: 2004-04-28
Posts: 16 |
![]() |
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? |
|
valiant
Joined: 2003-01-04
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. your options: b) instead of readfile(url), you could use GalleryEmbed::init(); GalleryEmbed::getImageBlock(); c) extend the imageblock:external controler to accept an url parameter, then call main.php with the correct parameters. |
|
plop1
![]()
Joined: 2004-04-28
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) require_once("http://www.mydomain.com/modules/gallery2/embed.php"); Any ideas on what I'm doing wrong? |
|
michiel_1981
Joined: 2005-05-19
Posts: 430 |
![]() |
i think activeUserId may not be "null", do you get any errors? |
|
plop1
![]()
Joined: 2004-04-28
Posts: 16 |
![]() |
Solved it! replace @readfile statement with: |
|
mtakacs
![]()
Joined: 2004-04-14
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. <?php require_once(dirname(__FILE__) . '/photos/embed.php'); GalleryEmbed::init(array('embedPath' => '/photos/', 'fullInit' => false )); list($ret,$content) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'none')); GalleryEmbed::done(); echo $content; ?> And yes, I read the docs at 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 |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
mtakacs, so, translating your fullInit = false to the new, corrected code is equal to fullInit = true. plop1, michiel is right, don't set 'activeUserId' => null, set it to 'activeUserId' => '' (empty string). |
|
michiel_1981
Joined: 2005-05-19
Posts: 430 |
![]() |
Strange i tried 'activeUserId' => '' (for quest users) i got this error: |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
michiel_1981, this slightly reminds of someone having the same error, but in standalone. what G2 version are you using? |
|
michiel_1981
Joined: 2005-05-19
Posts: 430 |
![]() |
hehe what clearing cookies can do. It worked. 0.9.18 |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
michiel_1981, good |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
ozgreg pointed out that fullInit is not needed for getimageblock. and he's right. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
Sorry, got to revert that statement. fullInit true is needed for getImageBlock(). |
|
plop1
![]()
Joined: 2004-04-28
Posts: 16 |
![]() |
All was well; however I've just noticed that a first time visitor to the site gets this error:
from require_once("modules/gallery2/embed.php"); $ret = GalleryEmbed::init(array('embedUri' => 'modules.php?name=gallery2', 'embedPath' => '/', 'relativeG2Path' => 'modules/gallery2', 'loginRedirect' => '', 'activeUserId' => 'Guest')); list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'title')); echo "$imageBlockHtml"; GalleryEmbed::done(); Tried, null '' & guest. Any ideas? (if user goes in and out of gallery2 the error goes away)[/] |
|
plop1
![]()
Joined: 2004-04-28
Posts: 16 |
![]() |
doh.. just reread the use of fullinit code now; require_once("modules/gallery2/embed.php"); $ret = GalleryEmbed::init(array('embedUri' => 'modules.php?name=gallery2', 'fullInit' => 'true', 'embedPath' => '/', 'relativeG2Path' => 'modules/gallery2', 'loginRedirect' => '', 'activeUserId' => '')); list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'title')); echo "$imageBlockHtml"; GalleryEmbed::done(); |
|