Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Mod to sort thumbnails by rating in album view  (Read 12852 times)

0 Members and 1 Guest are viewing this topic.

divestoclimb

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 16
Mod to sort thumbnails by rating in album view
« on: October 30, 2008, 07: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

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 16
Re: Mod to sort thumbnails by rating in album view
« Reply #1 on: December 22, 2008, 04: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: [Select]
$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: [Select]
  'rating' => 'RATING',
  'sort_ra' => 'Sort by rating ascending',
  'sort_rd' => 'Sort by rating descending',

In include/functions.inc.php, find the following section:
Code: [Select]
        $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: [Select]
  'ra' => 'pic_rating ASC, votes ASC',
  'rd' => 'pic_rating DESC, votes DESC',

Now in include/themes.inc.php, find the following:
Code: [Select]
        $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: [Select]
    '{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: [Select]
                                        <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: [Select]
                                        <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, 04:27:40 pm by divestoclimb »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Mod to sort thumbnails by rating in album view
« Reply #2 on: January 01, 2009, 06:54:10 pm »

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

cmead

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Mod to sort thumbnails by rating in album view
« Reply #3 on: November 04, 2009, 05: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

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 16
Re: Mod to sort thumbnails by rating in album view
« Reply #4 on: November 05, 2009, 12:41:48 am »

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
  • Offline Offline
  • Posts: 4
Re: Mod to sort thumbnails by rating in album view
« Reply #5 on: November 05, 2009, 10: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

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 16
Re: Mod to sort thumbnails by rating in album view
« Reply #6 on: November 09, 2009, 10: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: [Select]
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 :)
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.