Random images in the category view

Phoca Gallery - image gallery extension
symtalk
Phoca Member
Phoca Member
Posts: 14
Joined: 02 Dec 2009, 17:53
Contact:

Random images in the category view

Post by symtalk »

I configured images to show in a random order but the images are showing in the same order every time I refresh the page. This is in category view...

here is the link to my website

http://yenekonjo.com
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49149
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Random images in the category view

Post by Jan »

Did you set the right parameters (for the right itemid) in menu link to gallery, see:
https://www.phoca.cz/documents/16-joomla ... -in-joomla
If you find Phoca extensions useful, please support the project
symtalk
Phoca Member
Phoca Member
Posts: 14
Joined: 02 Dec 2009, 17:53
Contact:

Re: Random images in the category view

Post by symtalk »

Hey Jan, thanks for quick response...

Both in the menu and component configuration, I set it to be random in each group. Am I missing something?

Categories View Settings (List of Categories)
Categories Image Ordering - Random

Category View Settings (List of Images)
Categories Image Ordering - Random



Category View Settings (Categories above Images)
Categories Image Ordering - Random
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49149
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Random images in the category view

Post by Jan »

Hi, check the parameters, you can display images/categories as random but you can display image as folder icon as random. These are different parameters.

Jan
If you find Phoca extensions useful, please support the project
Amrit
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 29 Dec 2009, 18:00

Re: Random images in the category view

Post by Amrit »

Hi Jan.

Under General Settings I can choose Image Ordering.
However, there is no Random to choose from.

I checked in your ordering.php, and I saw that you have commented out // Random will be used e.g. ORDER BY RAND()

I know ORDER BY RAND () can be quite time consuming when having a lot of images, but I would really like to use Random of my images. I don't have so many images and therefore my gallery would look better with Random, and it is also how I want my images presented.

Is there any way of using ORDER BY RAND()
I tried to, but then I couldn't even get images to display at all.

Cheers
Amrit
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49149
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Random images in the category view

Post by Jan »

Hi, there should not be problem to order by random, see the parameters, if you are set the right parameters, there are more possible parameters regarding ordering (ordering of images in slideshow, ordering of categories, ordering of images, ordering of images for categories view, ...)

Jan
If you find Phoca extensions useful, please support the project
Amrit
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 29 Dec 2009, 18:00

Re: Random images in the category view

Post by Amrit »

Hi Jan.
Thanks for your answer.

I have now tried PhocaGallery 2.6.2 on three fresh installations.
None of them can have random view of the actual images.

So, I checked the file for Parameters.
I find four places in config.xml to set Random.
Categories Image Ordering (default option=9)
Category Image Ordering (default option=9)
Category Image Ordering CV (default option=9)
Slideshow Random

Categories Image Ordering, Category Image Ordering and Category Image Ordering CV has no effect whatsoever to change the ordering of images.

The ONLY place that I can set image ordering, on a fresh joomla and a fresh PhocaGallery, is with General settings -> Image Ordering.
However, Image Ordering under the tab General Settings doesn't have the option Random.
So I checked what function is used for image ordering.

In the file ordering.php, there is a class PhocaGalleryOrdering and it has a function called getOrderingString.
There are 10 case's in this function.
case 9 is blank, it has no ordering.

Code: Select all

<?php
/*
 * @package Joomla 1.5
 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 *
 * @component Phoca Gallery
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined( '_JEXEC' ) or die( 'Restricted access' );

class PhocaGalleryOrdering
{
	/*
	 * Set Ordering String if Ordering is defined in Parameters
	 */
	function getOrderingString ($ordering) {
		switch ((int)$ordering) {
			case 2:
				$orderingOutput	= 'ordering DESC';
			break;
			
			case 3:
				$orderingOutput	= 'title ASC';
			break;
			
			case 4:
				$orderingOutput	= 'title DESC';
			break;
			
			case 5:
				$orderingOutput	= 'date ASC';
			break;
			
			case 6:
				$orderingOutput	= 'date DESC';
			break;
			
			case 7:
				$orderingOutput	= 'id ASC';
			break;
			
			case 8:
				$orderingOutput	= 'id DESC';
			break;
			
			// Random will be used e.g. ORDER BY RAND()
			/* if ($imageOrdering == 9) {
					$imageOrdering = ' ORDER BY RAND()'; 
				} else {
					$imageOrdering = ' ORDER BY '.PhocaGalleryOrdering::getOrderingString($image_ordering);
				}
			*/
			case 9:
				$orderingOutput = '';
			break;
			
			// Is not ordered by recursive function needs not to be used
			case 10:
				$orderingOutput = '';
			break;
		
			case 1:
			default:
				$orderingOutput = 'ordering ASC';
			break;
		}
		return $orderingOutput;
	}
}
?>
So even if I wanted to use Random, according to the code in ordering.php, I can't use random, simply because it doesn't exist. (It's actually commented out)

To make it even more odd, when I change case 9: to use ORDER BY RAND()

Code: Select all

case 9:
$orderingOutput = 'ORDER BY RAND()';
break;
it doesn't work. In fact, no images are displayed at all.
I tried using LIMIT 20 aswell, just to see, but still no images displays.

To make matters more confusing, the random does work in Phoca Gallery Module, and in the module, random is done like this:

Code: Select all

if ($image_ordering == 9) {
	$imageOrdering = ' ORDER BY RAND()'; 
} else {
	$imageOrdering = ' ORDER BY a.'.PhocaGalleryOrdering::getOrderingString($image_ordering);
}
and this is the way PhocaGallery used to order images before, atleast according to the commented code in ordering.php, line 48-53.

So it seems the module has a random that DOES work, and the component DOESN'T have a random at all.

Even if it should work as you say Jan, there is, as far as I can see no code for the use of Random...

Thanks
Amrit
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49149
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Random images in the category view

Post by Jan »

Hi, I will take a look at it closer, maybe this is really missing there :idea: :(
For now you can customize the code so it is in the module.

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