PhotoPlog

PhotoPlog (http://www.photoplog.com/forum/index.php)
-   "How Do I..." Questions (http://www.photoplog.com/forum/forumdisplay.php?f=7)
-   -   Letterbar destination (http://www.photoplog.com/forum/showthread.php?t=1415)

devoslack 07-09-2007 10:06 PM

Letterbar destination
 
Is it possible for the Letterbar to link to the files that start with the selected letter, rather than linking to the user with the selected letter?

Example:

Currently if you click on D in the letterbar, you are taken to a list of users that have posted images.

I would like to:
Click D in the letterbar and be able to list all files that begin with D.

Morgan 07-09-2007 10:35 PM

Untested, but you would need to edit the if-block of code starting with the following in the PhotoPlog index.php file:
Code:

                        if (!$photoplog['user_id'] && !$photoplog['cat_id'] && $photoplog['letter_id'])
Maybe something like the following will do:
Code:

                        if (!$photoplog['user_id'] && !$photoplog['cat_id'] && $photoplog['letter_id'])
                        {
                                if ($photoplog['letter_id'] == '1')
                                {
                                        $photoplog_sql = "AND (SUBSTRING(" . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename, LOCATE('_', " . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename)+1) > 'Z' OR SUBSTRING(" . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename, LOCATE('_', " . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename)+1) < 'A')";
                                }
                                else
                                {
                                        $photoplog_sql = "AND SUBSTRING(" . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename, LOCATE('_', " . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename)+1) LIKE '".$db->escape_string($photoplog['letter_id'])."%'";
                                }
                                $photoplog_link = "q=".urlencode($photoplog['letter_id']);
                        }

Though note that, as functions are run on a field, it is not optimal to do this. Large galleries would definitely not, not, not want to do this, as there is a full table scan.

Again untested, but you could try this instead if you are not worried about missing files with the same name:
Code:

                        if (!$photoplog['user_id'] && !$photoplog['cat_id'] && $photoplog['letter_id'])
                        {
                                if ($photoplog['letter_id'] == '1')
                                {
                                        $photoplog_sql = "AND (" . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename > '1_Z' OR " . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename < '1_A')";
                                }
                                else
                                {
                                        $photoplog_sql = "AND " . PHOTOPLOG_PREFIX . "photoplog_fileuploads.filename LIKE '1_".$db->escape_string($photoplog['letter_id'])."%'";
                                }
                                $photoplog_link = "q=".urlencode($photoplog['letter_id']);
                        }

That should use an index but will miss files with the same name, catching only the first one for display.

devoslack 07-09-2007 10:39 PM

Alrighty. I expect the gallery to grow exponentially, if not during the summer then definitely during the next hockey season. I'll just remove the letter bar and allow users to search for their favorite players.

Thanks for the help!

MikeD 07-10-2007 08:05 AM

Quote:

Originally Posted by devoslack (Post 12446)
Example:
Currently if you click on D in the letterbar, you are taken to a list of users that have posted images.

I would like to:
Click D in the letterbar and be able to list all files that begin with D.

Exactly the same idea I had yesterday. See here :) -Mike

Statice 07-26-2007 12:47 AM

I've tried this and when i hit any letter it brings up the same files over and over

its not filtering anything.

possible solutions?

Morgan 07-26-2007 12:52 AM

Sorry, none, as I haven't tested that code though something like it should work.

Statice 07-26-2007 12:57 AM

i'm not too great with php...so i dont think i'd be able to figure it out lol

hmmm


All times are GMT. The time now is 12:08 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.