Making Images go to the front

Phoca Gallery - image gallery extension
HRT222
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 17 Sep 2008, 08:38

Making Images go to the front

Post by HRT222 »

Hey,

I am using Phoca Photo Gallery. I have about 200 images and around 5 cateogries. Every time I upload a new picture it goes to the back of the gallery. How can I make it so when I upload a new image it goes straight to the front?

Reordering the images in the backend is not an option when I have so many images and upload new images daily.

Anyone know how this can be achieved?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49134
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Making Images go to the front

Post by Jan »

Hi, if you upload images on your server then they are displayed in the list as they are listed e.g. in ftp client
If you find Phoca extensions useful, please support the project
HRT222
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 17 Sep 2008, 08:38

Re: Making Images go to the front

Post by HRT222 »

Ok so there is no setting for me to show images either assending or desending at the point of uploaded. Hmm strange and hope it comes with the next release.

Thanks anyway.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49134
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Making Images go to the front

Post by Jan »

there are two layers in Phoca Gallery
- database layer - images (image filenames) which can be displayed the way you want (order by name, ordering, ...)
- files layer - list of files on the server (there is no ordering function)

Jan
If you find Phoca extensions useful, please support the project
User avatar
philb
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 10 Feb 2009, 19:03
Location: Montréal, Canada
Contact:

Re: Making Images go to the front

Post by philb »

Hi there,

I had 206 images displaying in reverse order (from oldest to newest). Using the "order" in Joomla was out of the question.
For 206 images it would take forever to do.

The fast fix and have apply is a small PHP script I've created to reverse the order of all the images in the jos_phocagallery (default installation name) table. If you can't get in the front door... take the back door! :o

Here is the script:

Code: Select all

<?php
$db = mysql_connect("127.0.0.1", "yourUserName", "yourPassword");
mysql_select_db("yourDBName", $db);
$result = mysql_query("SELECT title,ordering FROM jos_phocagallery ORDER BY id", $db);

if($result !== FALSE){
    // We get the total number of items (images) returned
    $numrow = mysql_num_rows($result);
    while(($row=mysql_fetch_assoc($result)) != NULL){
        echo $numrow."&nbsp;|&nbsp;";

        // We get the name of the present image
        $image = $row['title'];
        echo $image."&nbsp;|&nbsp;";

        // We update the "ordering" value of the present image.
        // We start with the first image entered in the db (using the SORT BY id).
        // It is the one we want to have be diplayed last since it's the oldest so it's new 'ordering' value
        // will be equal to the total amount of items (images) returned.
        $update = mysql_query("UPDATE jos_phocagallery SET ordering=$numrow WHERE title=$image", $db);
        if(!$update){echo "erreur<br>";}
        else echo "<br>";

        // We decrement the counter so the next image will get a lower 'ordering' number.
        // It will end with an ordering number of 1 so the newest image will appear first and the oldest last
        $numrow = $numrow-1;
    }
}
mysql_close($db);
?>


Just create a PHP file with this code in it, upload it to your server and run it.
I know it's a pretty weird way to get around this problem but once you have the file with this script on your server it's as simple as running it.

Of course, when you add / remove an image you have to run the script again.
It is less of a pain that having to use Joomla "order" button unless you have just a few images in your gallery.

If there is presently a faster way to do this just let me know. I don't get enough sleep and might have missed it! :idea:

Hope this will help!

Philippe

P.S.: Use it at your own risk. If you don't know what you're doing ask for help. I'm will not be held responsible for any problem you encounter with this script. It is pretty simple and shout work for you.
"You're so Lucky!"
Chunyi Lin, Qigong Master
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49134
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Making Images go to the front

Post by Jan »

Hi, thank you for this script, Jan
If you find Phoca extensions useful, please support the project
leandar
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 14 May 2009, 06:16

Re: Making Images go to the front

Post by leandar »

thank you for your PHP code , but i got error
20 | asian-girl-9 | erreur
19 | asian-girl-10 | erreur
18 | asian-girl-11 | erreur
17 | asian-girl-12 | erreur
16 | indian-actress-1 | erreur
15 | indian-actress-2 | erreur
14 | indian-actress-3 | erreur
13 | indian-actress-4 | erreur
12 | indian-actress-5 | erreur
11 | indian-actress-6 | erreur
10 | indian-actress-7 | erreur


whats was wrong with me ?
HRT222
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 17 Sep 2008, 08:38

Re: Making Images go to the front

Post by HRT222 »

leandar wrote:thank you for your PHP code , but i got error
20 | asian-girl-9 | erreur
19 | asian-girl-10 | erreur
18 | asian-girl-11 | erreur
17 | asian-girl-12 | erreur
16 | indian-actress-1 | erreur
15 | indian-actress-2 | erreur
14 | indian-actress-3 | erreur
13 | indian-actress-4 | erreur
12 | indian-actress-5 | erreur
11 | indian-actress-6 | erreur
10 | indian-actress-7 | erreur


whats was wrong with me ?
Upgrade your Phoca Gallery version to the latest - the developers have put a setting in there to make the new images appear first in order. Well done to the team for actually doing it to. :D
leandar
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 14 May 2009, 06:16

Re: Making Images go to the front

Post by leandar »

HRT222 wrote: Upgrade your Phoca Gallery version to the latest - the developers have put a setting in there to make the new images appear first in order. Well done to the team for actually doing it to. :D
just i have Upgraded phoca gallery to latest 2.2.4 , please guide me where can i change this option from settings ?

EDIT >

i got this from parameters > global setting :D

Image

thank you very much for this healp :lol:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49134
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Making Images go to the front

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply