Member
Member
misterbrandt   2008-01-06, 20:31
#1

I haven't seen this addressed previously. Please let me know if it has.

I love the addition of tagging (and someday maybe a normalized database for them ), but I hate the URLs. So, I have a simple hack to make this:
http://elbedesign.com/zenphoto/index.php?p=search&searchfields=4&words=sometag
look like this:
http://elbedesign.com/zenphoto/tags/sometag

(this hack obviously requires that mod_rewrite is enabled. Well, I check to ensure that it is, so you can implement this hack on your site, but it won't do anything unless your server can support it (and zenphoto is configured to enable mod_rewrite)

I added these lines to the .htaccess:
` #### Rewrite rule for tags clean URL

SEE ALSO: hack in template-functions.php - FUNCTION "getSearchURL" -- insert 4 lines starting at line 1967


RewriteRule ^tags/(.*) index.php?p=search&searchfields=4&words=$1 [L,QSA]

`
(You have to add this rewrite rule ABOVE the "catch-all" rule)

and I added 4 new lines at the start of the getSearchURL function in template-functions.php (inserted lines start at line 1967 in release 1.1.3)
`function getSearchURL($words, $dates, $fields=0) {

if ( !empty($words) && empty($dates) && $fields==SEARCH_TAGS && getOption('mod_rewrite') ) { // elbe added (hack for clean tags URL)

// if request is for a "tags" url AND mod_rewrite is enabled, give them a clean /tags/ URL      // elbe added (hack for clean tags URL)

return WEBPATH."/tags/".$words;                                                                 // elbe added (hack for clean tags URL)

} // elbe added (hack for clean tags URL)

$url = WEBPATH."/index.php?p=search";

if($fields != 0) { $url .= "&searchfields=$fields"; }

if (!empty($words)) { $url .= "&words=$words"; }

if (!empty($dates)) { $url .= "&date=$dates"; }

return $url;

}

`

I can make the hacked versions of these files available for download if necessary, but it is a pretty easy edit (and I don't really trust myself to update the hack with every point release).

All standard disclaimers apply -- make backups, hack at your own risk, I cannot be held responsible for any unforseen breakage. but it works on my test site...

Administrator
Administrator
acrylian   2008-01-07, 11:35
#2

Good idea, we simply forgot rules for the tag search. I think we will implement that.

Administrator
Administrator
acrylian   2008-01-07, 14:45
#3

I took a deeper look to your hack. I reworked it so that it fits our general search paths which follows the zp custom page path like zenphoto/page/search. Now your tags path would be zenphoto/page/search/tagsjust to keep in line with the existing. Maybe we skip the page someday, I guess we kept it to avoid conflicts with album titles.

Additionally I have added mod_rewrite rules for result pagination (that you maybe forgot) and for the archive date search too. Both needed a little more tweaking that just getSearchURL.

I already sent it to my fellow developers for testing, so probably that will be in one of the next svns.

Member
Member
misterbrandt   2008-01-08, 03:52
#4

acrylian, good point about path consistency. I was actually inspired by this forum comment, which I forgot to reference in my initial post. So I just aped that URL structure.

Member
Member
steffen   2008-01-09, 10:03
#5

After updating to the most recent nightly build, the archive does not work anymore. The cause is related to "Changeset 1030". A click on the date link leads to an 404 page. Before I did the update, the url looks like this:
http://www.domain.com/gallery/index.php?p=search&date=2008-01
after update:
http://www.domain.com/gallery/page/search/archive/2008-01

Regards,
Steffen

Administrator
Administrator
acrylian   2008-01-09, 11:20
#6

Right, if mod_rewrite is enabled the path should look like that. That's what I added. Probably you need to update you htaccess file with the new rewrite rules. The file should be included in the nightly build (probably invisible on your system).

Member
Member
steffen   2008-01-09, 13:33
#7

I also copied your .htaccess file from the (latest) nightly build. Since my gallery is not installed in /zenphoto, I had to change the RewriteBase like this:

RewriteBase /zenphoto --> to RewriteBase /gallery

The new "clean URLs" does not work for me. I only get 404 pages. If I update just the template-functions.php and keep the older .htacces, I get the following error message:

Zenphoto Error: the requested object was not found. Please go back and try again.

Administrator
Administrator
acrylian   2008-01-09, 14:52
#8

Strange, it works for me. Only updating template functions.php without the new htaccess can't work.
Did you run setup.php after upgrading (that should set the rewritebase automatically)? Does archive work with disabled mod_rewrite?

Member
Member
steffen   2008-01-09, 15:16
#9

What I found out is, that the rewrite rule works for tags, but not for the archive. You can have a look on my temporary site: www.synnatschke.com/gallery

If you click on the tag "sandstone", you will find all the related pictures. But if you switch to the archive: http://www.synnatschke.com/gallery/?p=archive and click on "January (6)", you will get an error message.

Administrator
Administrator
acrylian   2008-01-09, 15:39
#10

Could you please post your htaccess file? Seems that there is something missing since the normal path http://www.synnatschke.com/gallery/index.php?p=search&date=2008-01 works.

Member
Member
steffen   2008-01-09, 15:44
#11

Sure! Here it comes...

htaccess file for zenphoto


NOTE: Change the RewriteBase below to the absolute path to your zenphoto directory.


RewriteEngine On

!!! Change this to the web path (eg: http://www.yourwebsite.com/photos --> /photos) !!!


RewriteBase /gallery


RewriteRule ^admin/?$ zp-core/admin.php [R,L]

RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule ^.*$ - [R,L]

RewriteRule index.php$ index.php [L,QSA]
RewriteRule ^page/([0-9]+)/?$ index.php?page=$1 [L,QSA]
RewriteRule ^page/([A-Za-z0-9-_]+)/?$ index.php?p=$1 [L,QSA]
RewriteRule ^(.*)/page/([0-9]+)/?$ index.php?album=$1&page=$2 [L,QSA]

Rewrite rule addtion for seach


RewriteRule ^page/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?p=$1&words=$2 [L,QSA]
RewriteRule ^page/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([0-9]+)/?$ index.php?p=$1&words=$2&page=$3 [L,QSA]

Rewrite rule addtion for archive-/date-search (needed to be separarted because of the same structur)


RewriteRule ^page/([A-Za-z0-9-]+)/tags/(.*)/([0-9]+)/?$ index.php?p=$1&searchfields=4&words=$2&page=$3 [L,QSA]
RewriteRule ^page/([A-Za-z0-9-
]+)/tags/(.*)/?$ index.php?p=$1&searchfields=4&words=$2 [L,QSA]
RewriteRule ^page/([A-Za-z0-9-]+)/archive/([A-Za-z0-9-]+)/?$ index.php?p=$1&date=$2 [L,QSA]
RewriteRule ^page/([A-Za-z0-9-]+)/archive/([A-Za-z0-9-]+)/([0-9]+)/?$ index.php?p=$1&date=$2&page=$3 [L,QSA]

RewriteRule ^(.)/image/(thumb|[0-9]{1,4})/([^/\]+)$ zp-core/i.php?a=$1&i=$3&s=$2 [L,QSA]
RewriteRule ^(.
)/image/([^/\]+)$ zp-core/i.php?a=$1&i=$2 [L,QSA]


Catch-all - everything else gets handled in PHP for compatibility.


RewriteRule ^(.*)/?$ index.php?album=$1 [L,QSA]

Member
Member
sbillard   2008-01-09, 16:28
#12

acrylian:

What does not work is the link generated when you click on a date in the archive. What I get for a url is:

http://testalbum.sbillard.org/page/search/archive/2003-07

This gives the Zenphoto Error: the requested object was not found. Please go back and try again. error message.

This is with the nightly build .htaccess and having run setup. (All other mod_rewrite stuff that I have tried is workign.)

Administrator
Administrator
acrylian   2008-01-09, 17:38
#13

Steffen: We or more exactly sbillard figured it out. You need to change the archives rules a little to
`RewriteRule ^page/([A-Za-z0-9-_]+)/archive/(.*)/?$ index.php?p=$1&date=$2 [L,QSA]

RewriteRule ^page/([A-Za-z0-9-_]+)/archive/(.*)/([0-9]+)/?$ index.php?p=$1&date=$2&page=$3 [L,QSA]`

It's in the next svn, too.

Member
Member
steffen   2008-01-09, 17:56
#14

Thank you for your support!

Member
Member
steffen   2008-01-10, 10:57
#15

The bug fix (htaccess) you released last night works only on the first page.

In my archive, I have 24 images for 1 month. 18 of them are shown on the first page, the other ones should be visible on the second page, but they dont. With mod_rewrite "on", I get the error "Sorry, no image matches. Try refining your search.". If I don't use mod_rewrite, I also get the second page with images. For verification, please see: http://www.synnatschke.com/gallery/page/search/archive/2008-01

Just another strange thing: I set the option "Image per page" to 15, which does not work properly, because I get 18 images on 1 page (see link above).

Administrator
Administrator
acrylian   2008-01-10, 13:38
#16

Could you please stop reporting bugs...:-)) You are right, there are two lines reversed in the htaccess:
' RewriteRule ^page/([A-Za-z0-9-]+)/archive/(.*)/?$ index.php?p=$1&date=$2 [L,QSA]
RewriteRule ^page/([A-Za-z0-9-
]+)/archive/(.*)/([0-9]+)/?$ index.php?p=$1&date=$2&page=$3 [L,QSA] `

That should be:

RewriteRule ^page/([A-Za-z0-9\-_]+)/archive/(.*)/([0-9]+)/?$ index.php?p=$1&date=$2&page=$3 [L,QSA] RewriteRule ^page/([A-Za-z0-9\-_]+)/archive/(.*)/?$ index.php?p=$1&date=$2 [L,QSA]
Sorry.

Regarding the images per page behaviour please look at this thread: http://www.zenphoto.org/support/topic.php?id=1911&replies=5

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.