Support Forum Project Downloads FAQ Documentation About Demo Tutorials Blog Plugins
November 21, 2009, 11:03:03 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Private messages disabled
Caused by the massive abuse of the PM system in the past, the sending of personal messages has been disabled for all regular users on the Coppermine forum.
[more]
   Home   Help Search Board rules Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Mod to sort thumbnails by rating in album view  (Read 3897 times)
0 Members and 1 Guest are viewing this topic.
divestoclimb Topic starter
Contributor
***
Posts: 16


« on: October 30, 2008, 06:21:18 pm »

I tried searching around for this and didn't see it: has someone already written a mod that will allow sorting of album thumbnails by rating in the same manner that one can sort by date, title, etc.?

I'm starting to work on writing one, but I want to make sure I don't waste my time reinventing the wheel.

(If the answer is no, I could use some quick tips for where to find the sorting code...)
Logged
divestoclimb Topic starter
Contributor
***
Posts: 16


« Reply #1 on: December 22, 2008, 03:19:47 pm »

Okay, I finally got around to doing this and once I really started looking it wasn't all that hard...

In lang/english.php (or in the language of your choice), find these lines:
Code:
$lang_thumb_view = array(
  'date' => 'DATE',
  //Sort by filename and title
  'name' => 'FILE NAME',
  'title' => 'TITLE',
  'sort_da' => 'Sort by date ascending',
  'sort_dd' => 'Sort by date descending',
  'sort_na' => 'Sort by name ascending',
  'sort_nd' => 'Sort by name descending',
  'sort_ta' => 'Sort by title ascending',
  'sort_td' => 'Sort by title descending',
  'position' => 'POSITION', //cpg1.4
  'sort_pa' => 'Sort by position ascending', //cpg1.4
  'sort_pd' => 'Sort by position descending', //cpg1.4
After these, add the following:
Code:
  'rating' => 'RATING',
  'sort_ra' => 'Sort by rating ascending',
  'sort_rd' => 'Sort by rating descending',

In include/functions.inc.php, find the following section:
Code:
        $sort_array = array(
          'na' => 'filename ASC',
          'nd' => 'filename DESC',
          'ta'=>'title ASC',
          'td'=>'title DESC',
          'da' => 'pid ASC',
          'dd' => 'pid DESC',
          'pa' => 'position ASC',
          'pd' => 'position DESC',
After this, add the following:
Code:
  'ra' => 'pic_rating ASC, votes ASC',
  'rd' => 'pic_rating DESC, votes DESC',

Now in include/themes.inc.php, find the following:
Code:
        $param = array('{ALBUM_NAME}' => $album_name,
            '{AID}' => $aid,
            '{PAGE}' => $page,
            '{NAME}' => $lang_thumb_view['name'],
            '{TITLE}' => $lang_thumb_view['title'],
            '{DATE}' => $lang_thumb_view['date'],
            '{SORT_TA}' => $lang_thumb_view['sort_ta'],
            '{SORT_TD}' => $lang_thumb_view['sort_td'],
            '{SORT_NA}' => $lang_thumb_view['sort_na'],
            '{SORT_ND}' => $lang_thumb_view['sort_nd'],
            '{SORT_DA}' => $lang_thumb_view['sort_da'],
            '{SORT_DD}' => $lang_thumb_view['sort_dd'],
            '{POSITION}' => $lang_thumb_view['position'],
            '{SORT_PA}' => $lang_thumb_view['sort_pa'],
            '{SORT_PD}' => $lang_thumb_view['sort_pd'],
After it, add this:
Code:
    '{RATING}' => $lang_thumb_view['rating'],
    '{SORT_RA}' => $lang_thumb_view['sort_ra'],
    '{SORT_RD}' => $lang_thumb_view['sort_rd'],

While still in include/themes.inc.php, find this section:
Code:
                                        <tr>
                                                <td class="sortorder_options">{POSITION}</td>
                                                <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa" title="{SORT_PA}">&nbsp;+&nbsp;</a></span></td>
                                                <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd" title="{SORT_PD}">&nbsp;-&nbsp;</a></span></td>
                                        </tr>
Add this after it:
Code:
                                        <tr>
                                                <td class="sortorder_options">{RATING}</td>
                                                <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=ra" title="{SORT_RA}">&nbsp;+&nbsp;</a></span></td>
                                                <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=rd" title="{SORT_RD}">&nbsp;-&nbsp;</a></span></td>
                                        </tr>

Note that if your theme has a custom value for $template_thumb_view_title_row in its theme.php, you will have to modify your theme to display the rating sort option similar to that last HTML block.
« Last Edit: December 22, 2008, 03:27:40 pm by divestoclimb » Logged
Joachim Müller
Administrator
*****
Gender: Male
Germany Germany

Posts: 45051


aka "GauGau"


WWW
« Reply #2 on: January 01, 2009, 05:54:10 pm »

Split totally unrelated reply by user "BIG" into separate thread.
Logged
cmead
Coppermine newbie

United States United States

Posts: 2


« Reply #3 on: November 04, 2009, 04:11:02 pm »

I made the changes to the code but cannot find the place where I select the RATING sort option...not on the config page.  Can you help?
Logged
divestoclimb Topic starter
Contributor
***
Posts: 16


« Reply #4 on: November 04, 2009, 11:41:48 pm »

Config page? You should see a "Rating" row underneath all the others in the sort area.

Here's my gallery as an example: http://forums.aopa.org/gallery/thumbnails.php?album=2 The sort options are on the right side: "Title, File Name, Position, ..., Rating"
Logged
cmead
Coppermine newbie

United States United States

Posts: 2


« Reply #5 on: November 05, 2009, 09:02:11 pm »

Wo...maybe I have no idea how to implement the changes you created - I'd love to get that sort option into the user interface..not sure how to do that. I was just trying to set the sort option in CONFIG to default showing the image with the highest votes first.

Sorry...newbie here.
Logged
divestoclimb Topic starter
Contributor
***
Posts: 16


« Reply #6 on: November 09, 2009, 09:43:37 pm »

Oh, I see what you're talking about now. I didn't make any changes to that in my mod, but to make it a default you'd need to do my mod then change admin.php.

As a hint, open up admin.php and search for this line:
Code:
function form_sort_order($text, $name, $help = '')
You'd need to add the options there, where you see the others listed. You would also need to add to the language strings in lang/english.php under $lang_admin_php.

If you take a look at the other parts of the mod it should be fairly easy to do. I'd walk you through it but I don't have the time to test and verify the exact changes that would be needed.

I'll bet you could also hack it into the database without changing the code, but I don't recommend it Smiley
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
Page created in 0.048 seconds with 17 queries.