Errors: "Undefined offset: -1" and "404 -Resource not found"

Phoca Gallery - image gallery extension
tranglos
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 29 Sep 2009, 00:35

Errors: "Undefined offset: -1" and "404 -Resource not found"

Post by tranglos »

I'm trying to get Phoca Gallery to work for the first time, so maybe I'm missing a part of the installation. (From the documentation it's not quite clear what is required, since each module/plugin is separate). I have managed to upload images and created a single test category. Using the Phoca button plugin I can create a gallery of thumbnails on a page. However, clicking any thumbnail displays a pop-up with the following message:

Code: Select all

Notice: Undefined offset: -1 in C:\srv\root\joomlartmoxybare\components\com_phocagallery\router.php on line 230
This is followed by a "404 - Resource not found" error.

This does not seem to be related to this problem: viewtopic.php?f=1&t=5205&start=0 since it's the first time I've ever downloaded and installed Phoca.

Looking at the error message and the relevant php code, the line in question is:

Code: Select all

$vars['catid']	= $segments[$count - 4];
So it appears that the expression $count - 4 evaluates to -1, which is not a valid array index. And sure enough, when I change that line and hard-code my category id instead of the expression, that error disappears:

Code: Select all

$vars['catid']	= 1;
So this might be a bug in Phoca: the expression evaluates to an invalid array index, but the script in router.php does not check for that possibility.

However, even when I apply my "fix", I still get the 404 error. I've been trying various combinations of settings, from the simplest

{phocagallery view=category|categoryid=1}

to more complex ones as shown in the examples. I'm using the button plugin, so it should not be creating invalid code. The error happens also with default Joomla 1.5 template.

I'll appreciate any help! Phoca is my only chance to show images, since no other gallery I've tried, including a commercial product, can even generate thumbnails for png files.

(I've tried to upload a screenshot, but the forum engine gives an error. You can see it here: http://ethervane.com/images/stories/phoca-error.png )

On edit: I've figured out that disabling SEF URLs fixes the problem, but this is not an acceptable solution. Does the gallery not work with "pretty" URLs?
tranglos
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 29 Sep 2009, 00:35

Re: Errors: "Undefined offset: -1" and "404 -Resource not found"

Post by tranglos »

Hi Mohican,

I have found a partial solution here:
viewtopic.php?f=1&t=5213

You need to install the menu module (currently mod_phocagallery_menu_v2.5.0.zip). Leave the module disabled, so that it doesn't show up on your pages. Installing the module adds a new "Phoca" menu item type in the menu editor. Create a Phoca menu item and link it to the gallery you want using the configuration options for the menu item.

Now the gallery should work correctly with pretty URLs.

And now for the strange thing: if you still have your standard menu item pointing to your article with the {phocagallery...} code, the gallery in that article will start working as well. It seems that the mere presence of the Phoca menu item fixes the 404 error. So you can hide the "special" Phoca menu item, and your article with the gallery should continue working.

I have no clue why this works, and it's really more of a workaround than a fix. It makes maintenance of the site more troublesome, since you have to keep a hidden, unused menu item for each gallery you want to display, but at least it solves the immediate 404 problem.
Post Reply