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: Reverse the order of the albums?  (Read 3635 times)

0 Members and 1 Guest are viewing this topic.

mattoz22

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Reverse the order of the albums?
« on: October 17, 2005, 02:59:45 am »

Hi,

I have added around 80 albums to my gallery.... Due to the way I added them currently it losts the oldest at the top and the newest at the bottom of the page.

Is there any easy way to make the gallery reverse the order of the albums? I dont want to use the admin panel to manually change the order of over 80 albums, I simply need it to reverse the order...

?

Thanks for any help! (have searched and not found what I need)..
« Last Edit: October 21, 2005, 06:57:22 am by Abbas Ali »
Logged

mattoz22

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Reverse the order of the albums?
« Reply #1 on: October 20, 2005, 08:39:05 am »

Nobody?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Reverse the order of the albums?
« Reply #2 on: October 20, 2005, 09:06:48 am »

are those 80 albums all in one category (or no category at all)? This is overkill, I recommend giving your site some structure that makes sense, instead of just reversing chaos (as you will still get chaos no matter what). As a nice side-effect, it'll get easier to change the order in the albums manager. Post a link to your site if you want detailed recommendations. After all, post the link anyway please.
If you really need just the reverse, you could come up with a mod that reverses the order in the code that displays index.php, however I recommend running a query once that does this.
Logged

mattoz22

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Reverse the order of the albums?
« Reply #3 on: October 20, 2005, 03:39:23 pm »

Due to the nature of the site I do only have one category....

Here it is... www.ozziness.com

I would rather put something into the code somewhere to simply reverse it, if thats somehow possible?
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Reverse the order of the albums?
« Reply #4 on: October 20, 2005, 04:31:51 pm »

OK, in index php find in the function list_albums()
Code: [Select]
' ORDER BY a.pos '.and replace with
Code: [Select]
' ORDER BY a.pos DESC '.
the second occurance doesn't matter cause you don't use cats: That should do ;)

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Reverse the order of the albums?
« Reply #5 on: October 20, 2005, 04:42:14 pm »

As GauGau already said you have two options. First changing the query on index.php which retrieves the album data from database and second running a query/script for once which will change the positions of albums directly in the database. Both the methods are explained below.

Method 1 (Chaning query on index.php)
Edit index.php

Replace

Code: [Select]
$sql = 'SELECT a.aid, a.title, a.description, visibility, filepath, '.
           'filename, url_prefix, pwidth, pheight '.
           'FROM '.$CONFIG['TABLE_ALBUMS'].' as a '.
           'LEFT JOIN '.$CONFIG['TABLE_PICTURES'].' as p '.
           'ON a.thumb=p.pid '.
           'WHERE category='.$cat.$album_filter.
           ' ORDER BY a.pos '.
           $limit;

with

Code: [Select]
$sql = 'SELECT a.aid, a.title, a.description, visibility, filepath, '.
           'filename, url_prefix, pwidth, pheight '.
           'FROM '.$CONFIG['TABLE_ALBUMS'].' as a '.
           'LEFT JOIN '.$CONFIG['TABLE_PICTURES'].' as p '.
           'ON a.thumb=p.pid '.
           'WHERE category='.$cat.$album_filter.
           ' ORDER BY a.pos DESC '.
           $limit;

Method 2 (Changing the pos in database)
Do take a backup of albums table before running this code

Create a new script reverse.php with following code and place the script in coppermine root folder.

Code: [Select]
<?php
define
('IN_COPPERMINE'true);
define('LOGOUT_PHP'true);
require(
'include/init.inc.php');
if (!
GALLERY_ADMIN_MODE) {
  
cpg_die(ERROR$lang_errors['perm_denied'], __FILE____LINE__);
}
$query "SELECT count(aid) AS count FROM {$CONFIG['TABLE_ALBUMS']}";
$result db_query($query);
$row mysql_fetch_assoc($result);
$albCount $row['count'];

$query "SELECT pos,aid, title FROM {$CONFIG['TABLE_ALBUMS']} ORDER BY pos ASC";
$result db_query($query);
while (
$row mysql_fetch_array($result)) {
  
$newPos 100 $albCount;
  
$aid $row['aid'];
  
$sql "UPDATE {$CONFIG['TABLE_ALBUMS']} SET pos = '$newPos' WHERE aid = '$aid'";
  
$albCount--;
  
$update db_query($sql);
  if (
$update) {
    echo 
"Album '{$row['title']}'  =>   Old pos={$row['pos']}  New pos=$newPos<br>";
  }
}
?>


After creating the script run it once. This will reverse the order of your albums. After successfully reversing the order of albums i recommend deleting the script.

NOTE:
  • Apply only any one method
  • Before doing any changes through the script, do take a backup of albums table
  • Run the script as admin

Abbas

P.S: Stramm already posted the first solution when i was composing this message. Anyways i am still posting.
Logged
Chief Geek at Ranium Systems

mattoz22

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Reverse the order of the albums?
« Reply #6 on: October 21, 2005, 02:03:44 am »

Thank you both so much for your time. Both methods worked perfectly.

I editted index.php as a quick fix but will eventually get around to doing it the proper way... and hey one day I might even use categories ;)
Logged

calvin123

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Reverse the order of the albums?
« Reply #7 on: October 25, 2005, 12:34:28 am »

Hi, I tried your changes and they work perfectly, but to make it a consistent solution I would
propose that you also change the "list_cat_albums"-function and reverse the order albums
are displayed on the main-page.

I added at the end of the "sql"-string also a "ORDER BY pos DESC" - now it looks as follows:

$sql = "SELECT a.aid, a.title, a.description, visibility, filepath, " . "
           filename, url_prefix, pwidth, pheight " . "
           FROM {$CONFIG['TABLE_ALBUMS']} as a " . "
           LEFT JOIN {$CONFIG['TABLE_PICTURES']} as p
           ON thumb=pid " . "WHERE category = '$cat' ORDER BY pos DESC " . "$limit";

Greetings Stefan
P.S.
(Sorry for my bad english, but I'm a little bit out of training)
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 20 queries.