Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 06:22 am EDT

Geeklog Forums

Multiple Galleries Problem


Status: offline

laughable

Forum User
Newbie
Registered: 02/18/04
Posts: 7
I have a site that supports two seperate photographers. We are running two embedded installations of Gallery.....

And would like to use the Random Gallery block and they standard Gallery Block on the main page for both Gallery installations.

This doesn't work with the current incarnation of these blocks, because the both call /path/to/gallery/init.php

And then gallery is confused about its context. That is both the RandomBlock & the Gallery Block have to point to the same gallery basedir for the php to work its magic.

Multiple incarnations of either of those blocks also must point to the same basedir.

IANAC (I am not a coder), I don't even play one on tv. Could someone please assist....
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
If you have two separate gallery installs, I see no problem with installing the blocks you want two different times, pointing one install to the first gallery instance and the second install to the second gallery instance. Thus, one block calls /path/to/first/gallery/init.php and the other calls /path/to/second/gallery/init.php.

Just make sure that you name everything uniquely. For example, you will need two separate cache files for the random-photo block.
 Quote

Status: offline

laughable

Forum User
Newbie
Registered: 02/18/04
Posts: 7
I believe I have "been there.. done that" because of course that was my first guess as to how to skin the beast. Seperate out everything right down to the function naming in lib-custom....
But I get no joy.....
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
Well, what went wrong? Any error messages? Are you sure you didn't forget to rename something?
 Quote

Status: offline

asmaloney

Forum User
Full Member
Registered: 02/08/04
Posts: 214
Yeah, the problem is in the inclusion of two init.php files, as they try to declare the same functions twice:

PHP Fatal error: Cannot redeclare editfield() (previously declared in /.../gallery2/util.php:33) in /.../gallery/util.php on line 33

I don't really know how to work around this, but let me think about it some more. I wish PHP had namespaces...

[Just had flashbacks to COBOL's COPY...REPLACING statements <shudder>.]
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
What if you remove:

require($GALLERY_BASEDIR . "util.php");

from the second instance of Gallery? (Make sure that is the one that is loaded second.)
 Quote

Status: offline

asmaloney

Forum User
Full Member
Registered: 02/08/04
Posts: 214
Quote by Turias: What if you remove:

require($GALLERY_BASEDIR . "util.php");

from the second instance of Gallery? (Make sure that is the one that is loaded second.)


No, there are too many functions and classes which are included twice for this work.
 Quote

Status: offline

laughable

Forum User
Newbie
Registered: 02/18/04
Posts: 7
Thanks guys! I am glad to hear you're on the case.
 Quote

Status: offline

laughable

Forum User
Newbie
Registered: 02/18/04
Posts: 7
New problem... for mr. maloney.
I can run Random block in an anonymous context (not logged in) for both gallery installs. (ON seperate pages As you correctly duplicated my

PHP Fatal error: Cannot redeclare editfield() (previously declared in /.../gallery2/util.php:33) in /.../gallery/util.php on line 33


And I can run your GalleryBlock in Admin mode or logged in, but _NOT_ in an anonymous context.

I get

Fatal error: Call to a member function on a non-object in /var/www/rklphoto/classes/User.php on line 136

1.) on multiple browsers/machines
2.) having removed all my duplication hacks (fresh from the tar)
3.) reinstalled thegallery integration package fresh from the tar)

Again things look fine whil I am logged in but as soon as I log out.. *Smack* I get an error.

Any thoughts?
 Quote

Status: offline

asmaloney

Forum User
Full Member
Registered: 02/08/04
Posts: 214

As far as I can tell, using more than one gallery installation with the Gallery Block is not going to be possible with PHP 4. The problem is we cannot include the required files from multiple galleries because they define the same functions. As far as I can tell there's no way to limit the scope of the funcions in the included files to allow for this.

Now, PHP 5 might have namespaces which could potentially be used to solve this [how many conditionals can I possibly use?], but I think that's a long way off.

Does anyone with more knowledge of PHP have any suggestions?

[w.r.t. the 'new problem', I can't reproduce it and am waiting for more info from 'laughable'. If anyone else has similar problems, please contact me.]
 Quote

Status: offline

asmaloney

Forum User
Full Member
Registered: 02/08/04
Posts: 214
Quote by asmaloney:
[w.r.t. the 'new problem', I can't reproduce it and am waiting for more info from 'laughable'. If anyone else has similar problems, please contact me.]

The 'new problem' has been solved. It was caused by newlines in some of the album titles. I have fixed this and a couple of other things and put v1.0.1 on my website [IMoL].
 Quote

laughable

Anonymous

I just wanted to publically thank Andy. He made an excellent plugin and was incredibly helpful resolving this issue.



Somebody should buy him a beer.

--laughable
 Quote

All times are EDT. The time is now 06:22 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content