Arrow

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.)

Arrow

3 Responses to “How to bypass / omit the collections view in Plogger”


  1. j.haglund says:

    awesome, just what i was looking for! thanks!


  2. Kratos says:

    Thanks mate, works perfectly.


  3. 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

Speak your mind

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word