Fatal error with Gallery random block in MOS 4.5.1...

erik1971

Joined: 2004-09-30
Posts: 2
Posted: Thu, 2004-09-30 22:08

When I try to add a random image block for Gallery 1.4.4-pl2 with Mambo 4.5.1 I get this nasty error in my block when clicking the image or album link (This error also comes when I try to click the embedded gallery link in my mambo main menue):

Fatal error: Cannot redeclare editfield() (previously declared in /hsphere/local/home/deepeco/deepeco.net/mambo/gallery/util.php:27) in /hsphere/local/home/deepeco/deepeco.net/mambo/gallery/util.php on line 27

:roll:

The module code:

<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $GALLERY_EMBEDDED_INSIDE;
global $GALLERY_EMBEDDED_INSIDE_TYPE;
global $GALLERY_MODULENAME;
global $include;
global $option;

$option = "com_gallery"; // Tells Gallery that we're inside Mambo
$include = "block-random.php"; // ... and that we want block-random.php.
//define ('GALLERY_URL',"/path/to/your/gallerybasedir");

$database->setQuery('SELECT `value` FROM #__gallery WHERE `field` = \'path\'');
define ('GALLERY_URL',$database->loadResult() );

$GALLERY_MODULENAME = $option;
$GALLERY_EMBEDDED_INSIDE = 'mambo';
$GALLERY_EMBEDDED_INSIDE_TYPE = 'mambo';

include(GALLERY_URL . "/$include");

?>

Without the random image block the gallery/mambo relationship works just fine... Any obvious n00b mistake I'm doing or a remedy? (My mambo test site: http://deepeco.net/webdesign)

:-?

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Fri, 2004-10-01 00:20

Add this line just above the $GALLERY_MODULENAME = $option line:

$GALLERY_NO_SESSIONS = true;

-Beckett (

)

 
ac07080

Joined: 2003-01-14
Posts: 29
Posted: Fri, 2004-10-01 03:32

I'm getting the same error even after adding the line you mentioned

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2004-10-01 03:40

The problem is that Gallery *requires* the random block to be included via HTTP. It can't be included as a direct file.

include("http://your.site/path/to/gallery/block-random.php")

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Fri, 2004-10-01 04:27

ac07080,
Oops I meant to have you add that line to the top of that code, above the block-random.php include. My bad... I didn't read your code closely enough.

signe,
Hm. I had no idea! What requires it to be that way (i.e. not directly includable, but only via HTTP)? (I was previously frustrated with a some of the changes recently in the random block, but perhaps I just didn't understand!). I add the $GALLERY_NO_SESSIONS variable, and everything seems to work...

-Beckett (

)

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2004-10-01 06:15

beckett, it's because, while it may not be a problem while viewing other places in the site, Gallery isn't setup to include the same file multiple times.

For instance, if util.php is loaded in the random block, and a user tries to view Gallery on a page where the random block is also present, you'll get errors (like the redefine) because util.php was included twice. The second include will cause the error.

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Fri, 2004-10-01 21:55

Are we still supporting PHP versions pre-require_once()?

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Fri, 2004-10-01 22:02

No

Quote:
require_once() was added in PHP 4.0.1pl2

Even before the changes in 1.4.5, we supported 4.0.4pl or higher.

The problem is that I've looked at what would be necessary to achieve an inline-include of the block, and I don't know if it's possible at this time. G1 just doesn't have a robust-enough structure to take that massive a change without a lot of work.

 
erik1971

Joined: 2004-09-30
Posts: 2
Posted: Sat, 2004-10-02 07:54

The Random block will work without changing any of the code, but not on the page together with the Gallery. So if "All" is chosen in the module position managar, the random image block won't work on any page... If the block is set up to show up just on the front page everything is fine...

:wink:

n00b me...

:oops: