How to bypass / omit the collections view in Plogger
First published on November 24, 2007
Plogger is a nifty little photo gallery script for those who want to host their own photos. I used to be a fan of Gallery but the simplicity and essential features of Plogger are far more attractive.
Anyway, Plogger structures a gallery as follows:
Collections > Albums > Photos
However, what if you only have a few albums and don’t necessarily wish to group them in collections? In other words, skip the collections view.
Suppose your gallery address is “funkypics.com/pictures”.The way it is currently set up, when you view the root of your photo gallery (“/pictures”), you view a list of collections, then you click on a collection to view a list of albums (“/pictures/?level=collection&id=1″), then you click on an album to view its photos (“/pictures/?level=album&id=2″). It would be more user-friendly to just bypass the collections step. In other words, when you access “/pictures”, you would automatically view “/pictures/?level=collection&id=1″.
Instead of hacking the core code (which complicates things when you upgrade software), you can bypass the collections level by using a rewrite rule. Rewrite rules basically change the URL that is processed by the server, given a particular circumstance. This is a bit different than simply redirecting a page and is often transparent to the user.
Here’s the code I use, which should be placed in a file called “.htaccess” in the root of your Plogger installation:
RewriteEngine On # Only URLs without a query string (an example of a query string is "?album=1") will be rewritten RewriteCond %{QUERY_STRING} ^$ # Rewrite all root directory requests to the album view RewriteRule !(.+)$ http://pathto/plogger/?level=collection&id=1 [L]
(This assumes that the ID of the only collection in your gallery is 1.)
February 26th, 2008 at 3:48 pm
j.haglund says:
awesome, just what i was looking for! thanks!
April 12th, 2009 at 7:04 am
Kratos says:
Thanks mate, works perfectly.
February 3rd, 2011 at 8:33 am
Admin says:
worked for me as well, however PLogger had already created a few definitions in .htaccess. Mine looked like this after adding two lines from your example:
# BEGIN Plogger
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /pl
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule ^.*$ http://www.mysite.com%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^(.*)$ http://www.mysite.com/pl/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ – [S=2]
RewriteRule feed/$ plog-rss.php?path=%{REQUEST_URI} [L]
RewriteRule ^.*$ index.php?path=%{REQUEST_URI} [L]
# Only URLs without a query string (an example of a query string is "?album=1") will be rewritten
RewriteCond %{QUERY_STRING} ^$
# Rewrite all root directory requests to the album view
RewriteRule !(.+)$ http://www.mysite.com/?level=collection&id=1 [L]
</IfModule>
# END Plogger