Fresh full install of G2 and Gallery - all working fine except in my Drupal Navigation menu I can't seem to get rid of menu items for new top level albums in the gallery. Even when I disable all menu items under "navigation" menu items persist. My test site with the problem is http://friendsoftheinyo.org/foi/ and the unwanted menu items are the "landscapes...", "Service...", and "wildlife...". Any new album gets a link automatically, it seems. I tried to find every nook and cranny for the proper setting... I'm probably missing some obvious thing, apologies if so; thanks for any assistance.
TV

Comments

profix898’s picture

Can you please add some details about your configuration (paths, etc.). It looks like a url rewrite issue to me. You should usually not see the 'index.php' in your url, e.g. http://friendsoftheinyo.org/foi/index.php/v/serviceprojects should be sth. like http://friendsoftheinyo.org/foi/gallery/v/serviceprojects. Make sure to set your 'Show Item' rule in G2 to 'gallery/v/%path%'.

Toddv’s picture

Thank you for a quick response and your suggestions. I checked the url rewrite rule for "Show Item" and it was /v%path%. I changed it to "gallery/v/%path% but that did not fix the problem.

I forgot to mention that the unwanted menu items don't actually link to the galleries they suggest they link to - they just bring up the front page.

So, more detail:
We have an old, functioning non-drupal site at friendsoftheinyo.org (with another gallery install)
Within that is the test site friendsoftheinyo.org/foi
The gallery I'm using there is a completely separate installation and is installed in friendsoftheinyo.org/foi/gallery2
Gallery's data directory is above the site root as suggested and is "g2data"
The imbeded gallery module is in friendsoftheinyo.org/foi/modules

The only other URLrewrite rules that are active are the "Coonnect to WebDAV" and "Mount WebDAV" rules.

I appreciate the help but I'm not sure: what other additional details would be helpful? Thank you,
TV

profix898’s picture

What G2 rewrite rules are contained at the top of your .htaccess file? It should be sth. like this ...

RewriteCond %{THE_REQUEST} /foi/gallery/v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/index\.php$
RewriteRule .   /foi/index.php?q=gallery&g2_path=%1   [QSA,L]

... but I suspect them to be slightly different, right?

Edit: I you wish you can check the configuration of one of my test installs (http://scratch.profix898.de/drupal5/, test1/test1) to compare with your own setup. It is a similar configuration (installed in a subfolder called /drupal5/ instead of your /foi/).

Toddv’s picture

Thank you again.
This is way over my head: This is the pertinent part of my .htaccess file:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /foi/admin/(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . /foi/main.php?g2_view=core.SiteAdmin [QSA,L]
RewriteCond %{THE_REQUEST} /foi/d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3&g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT [QSA,L]
RewriteCond %{THE_REQUEST} /foi/v/([^?]+)/slideshow\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . /foi/main.php?g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /foi/c/add/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . /foi/main.php?g2_view=comment.AddComment&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /foi/key/([^?/]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . /foi/main.php?g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /foi/v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/foi/main\.php$
RewriteRule . /foi/main.php?g2_path=%1 [QSA,L]

I looked at your test site. It is nice how the gallery album menu is in the Navigation block.
Thank you,
TV

profix898’s picture

1. This is the .htaccess file from your G2 directory (I guess). But the rewrite rules for Drupal are in the .htaccess file in Drupal's root folder.
2. You mention that you dont have other rewrite rules enabled, but this file contains rules for slideshow, comments, keyword albums, etc. (not just 'Show Item' and 'WebDav *')

Toddv’s picture

I'm sorry - I should of specified. That .ht file is from my /foi drupal root folder. There is no .htaccess file in my gallery2 directory. However, the g2data directory has an .htaccess file and it has the rewrite engine set to off.

Regarding rules, what I said was "The only other URLrewrite rules that are active are the "Coonnect to WebDAV" and "Mount WebDAV" rules." However I see in the .htaccess file that Gallery thinks otherwise. In the gallery>admin>url rewrite rules the settings are active only for the Connect to webdav, Mount webdav, and show item settings.

profix898’s picture

Does Gallery2 have permission to alter Drupal's .htaccess file? What are the filesystem permissions set to? Try to set them to 666 (or even 777) and resave the rewrite settings in G2 ... The .htaccess rules not being updated correctly by G2 is certianly the cause for your problems :(

Toddv’s picture

Again, thank you for your attention to my issue.

1. Apologies - where would I check to see if Gallery's file system permissions allow it to alter Drupal's .htaccess file. (or if Drupal's file system allows Gallery2). Is this the proper way: The file system permission in gallery/admin are 755 for directories and 644 for files. Temporarily changing the permission to 777 on the drupal .htaccess file and then resaving the rewrite settings from Gallery2 did not change the .htaccess file in the Drupal ("foi") directory.

2. I discovered that if I went to administer>site configuration > Gallery settings >menus > menu items and unchecked all the options that the menus I don't want in the navigation menu function properly - that is, they don't appear. This might fix the symptom but obviously not the problem...

3. Which .htaccess file is the problem, the one above the website root, in directory "g2data" (where url rewrite mode if off), or the .htaccess file in the Drupal installation directory.
Thank you,
TV

profix898’s picture

Temporarily changing the permission to 777 on the drupal .htaccess file and then resaving the rewrite settings from Gallery2 did not change the .htaccess file in the Drupal ("foi") directory.

Hmm. Thats strange and doesnt help to solve the problem ... I'll search for options as time permits ...
As a workaround you can try to manually replace the rules in Drupal's .htaccess files with this (hope its correct):

# BEGIN Url Rewrite section
# (Automatically generated.  Do not edit this section)
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /foi/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_URI} !/foi/index\.php$
    RewriteRule .   -   [L]

    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule .   /foi/gallery2/modules/webdav/data/options/   [QSA,L]
    RewriteCond %{THE_REQUEST} /foi/gallery/v/([^?]+)\.davmount(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/foi/index\.php$
    RewriteRule .   /foi/index.php?q=gallery&g2_view=webdav.DownloadDavMount&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /foi/gallery/w(/[^?]*)?(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/foi/index\.php$
    RewriteRule .   /foi/index.php?q=gallery&g2_controller=webdav.WebDav&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /foi/gallery/v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/foi/index\.php$
    RewriteRule .   /foi/index.php?q=gallery&g2_path=%1   [QSA,L]
</IfModule>

# END Url Rewrite section
I discovered that if I went to administer>site configuration > Gallery settings >menus > menu items and unchecked all the options that the menus I don't want in the navigation menu function properly - that is, they don't appear. This might fix the symptom but obviously not the problem...

The items are generated by the gallery_menu.module. You can even disable it completely to get rid of the items and this doesnt affect the main gallery integration.

Which .htaccess file is the problem, the one above the website root, in directory "g2data" (where url rewrite mode if off), or the .htaccess file in the Drupal installation directory.

The one in the Drupal folder. The .htaccess file in your g2data folder is only to protect it from being accessed directly (although not really needed in your case as the folder is not public).

Toddv’s picture

Thanks for the code. I'll try that.

Is there any merit in uninstalling and reinstalling the URL rewrite module?

I have discovered some other problematic behavior in Gallery2 - I set everyone's permission to view all versions, [digibug] print, and [shutterfly]Print but only the rules in the .ht file are appearing. Same problem, I guess. I'll keep playing with it. I'm tempted to remove it all and re install everything.
Thanks much for your help.
TV

profix898’s picture

Did you check the filesystem (absolute) path to your Drupal's .htaccess file in 'Embedded Setup' on the 'Setup' tab (admin > url rewrite > setup)? Just to make sure, G2 is not trying to update something else ;)

Is there any merit in uninstalling and reinstalling the URL rewrite module?

Not sure. I suggest you simply try. Actually I never had the same problem myself. What means I can only guess why your .htaccess file is not updated ... Sorry!

Edit: If your site is not critical would you temporarily grant me access (pm me)? Not sure I can help, but who knows ... :)

Toddv’s picture

You are on to something here.
The setup tab produces this: "The parser you have selected does not support a referer check."

So, I uninstalled the URLrewrite module. Then I reinstalled and configured. During that process I chose the "PHP Path Info" method - thinking that previously I had chosen the "Apache mod_rewrite" however I got the "The parser you have selected does not support a referer check." message.

Thus I repeated the process but chose "Apache mod_rewrite". Now I put an empty text file called .htaccess w/ permissions temporarily set to 777 at path .../gallery2/ (full path entered in the admin panel).

However gallery admin then says "An error occured while trying to save your settings
Cannot write to the .htaccess file"
Any thoughts on that?

I suspect the problem is in my lack of understanding, not a module problem.

Thanks so much! Your support on this has been outstanding.

Toddv’s picture

Status: Active » Fixed

Following up to this -
Thanks to your help, I fixed this problem. It was an issue with apache mod-rewrite module not being configured properly thus the rewrite rules were not being created. So a couple of learnings for me that may be useful to others: in the embedded gallery>admin>url rewrite>set up tab you can't ignore the "parser ... does not support..." message.

TV

profix898’s picture

Could you please provide some more details on how you fixed the problem? It would be helpful for others to know. There already is a second issue in the queue from a user experiencing the same problem of rewrite rules not being written correctly to .htaccess (not writable message). Thanks in advance.

Toddv’s picture

Even once I got Drupal>admin>gallery configured to indicate the settings were ok, clicking on a thumbnail back in the gallery still produced a 404. Critical errors were: The "show item" rule was wrong AND saving the rules from gallery2>admin>urlrewrite wrote to the wrong .htaccess file. The path to that was set wrong. That is to say, gallery2 was saving changes to mydrupalinstall/gallery2/.htaccess but drupal/gallery-embed was looking for a rule in mydrupalinstall/.htaccess.

Not sure all these steps were necessary but this is what I did; hope this is helpful.

1. I made sure the un-embedded Gallery2 was updated and functioning properly.
2. I deactivated and uninstalled URL-rewrite module from within gallery2's administration, then re-installed and reactivated it. Somewhere in there I ran the database update process from within gallery2/admin/maintenence.
3. I logged out of Gallery
4. Back in Drupal I deactivated and un-installed the gallery-embed module (i find the name confusing but I am referring to the module called "gallery")
5. In Drupal's ht access file I removed any reference to the rewrite rules. I started at the top of the file at the comment describing the rewrite, all the way down to the comment ending the rewrite rules. I'm sure this was more than was necessary but all that code is way over my head and this was the easiest way to make sure I had a fresh slate.
6. In Gallery2's htaccess file I also made sure there were no conflicting rules.
7. Ok, now basically have a fresh start with a functioning, non-embedded gallery and a drupal installation that doesn't know I care to embed any galleries...
8. CAREFULLY follow the instructions provided in the gallery-embed Read-me file
9. (emphasizing the gallery-embed instructions) in drupal>admin>site configuration>gallery settings>Install >>clean url/url rewrite make sure the path to the drupal .htaccess file is correct
10. In gallery2>admin>urlrewrite>rules make sure the rules are changed as the helper text back in the gallery-embed window indicates. eg under "show item" add the "gallery/". Remember to hit the "save' button at the bottom of the admin window.
11. I then viewed the .htaccess file to confirm the proper change was done. For us non-coders that is a little tough to sort out but a careful before/after look finds the change.

Some suggestions that might help avoid this:
-The names are confusing. We've got gallery2, gallery (what I'm calling gallery-embed) and Drupal's gallery. I'm still not clear on why add "gallery/" in the rules - which gallery is THIS "gallery" referring to? I don't really care - I'm just glad it works.
-This is really a beginner thing but in the helper text in your gallery configuration/install it might help to have a bit more of a description on the server path and public path. It would of helped me anyway.

I'll think about this some more and if I can be more clear I'll update this.

Edit: permissions were set to 644 on the .htaccess file. I don't think this was a permission issue.
Edit: to reiterate, critical in solving this "can't write .htaccess file was
1. making sure I knew where the .htaccess file was and the server path to it.
2. It was necessary for me to use manual entry option in gallery>configuration>install
3. confusingly, in gallery2>admin>urlrewrite>setup Gallery2 says "...you need to set up an extra.htaccess file to hold the mod_rewrite rules." I did not set up an extra file -but initially, when I had the "can't write .htaccess file" message, I had created this file. What i did was enter the proper absolute path to my drupal's .ht access file. I think my main problem was I had initially entered the wrong path. After a few experiments with the path, and repeated "can't write to the .htaccess file" I hit on the proper syntax for my server (/home/myusername/public_html/mydrupalinstall). I clicked "save" and it worked.

Thanks much for your help,
TV

jacki’s picture

STOP SENDING EMAIL TO ME. REMOVE ME FROM ALL EMAIL AND CANCEL MY ACCOUNT!!! SINCE I CAN NOT FIND OUT HOW TO DO IT ON DRUPAL SITE I WILL BE RESPONDING TO EACH EMAIL WITH THIS MESSAGE!!! LEAVE ME ALONE DRUPAL. I NO LONGER USE DRUPAL THEREFOR UNINTERESTED IN GETTING YOUR EMAILS!!!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

iMinnesotan’s picture

Thank you thank you!!! The steps in #15 fixed a problem I've been trying to solve for days! I'm on 6.x