Need help to change Random and Last Additions Thanks Need help to change Random and Last Additions Thanks
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Need help to change Random and Last Additions Thanks

Started by mookoo, July 01, 2005, 11:26:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mookoo

I have seen similar posts but not similar enough for me to work out what to do.

My site is primarily a gallery of my images but I do provide a user gallery feature. I want to limit the thumbnails in the Random and Last Uploaded to just the main categories (my images) on the initial page. However if you then select the user galleries section, I want the Random and Last Additions to display as normal i.e. display user images. I would have thought that other people with Coppermine galleries would find this handy too. It's ok to offer an upload service on your site but you don't necessarily want user images dominating your home page.

I have tried adding "where cid <> 1 AND" in the functions.inc.php file as a similar mod was done except with the aid field in a previous post. I assume it didn't work because the query is not in the right table to extract the cid value:

Example from Random section
$sql = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE cid <> 1  AND approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2";

I have also tried restricting the displayed images to just my owner_id (either 1 or 4) as follows:

Example from Random section
$sql = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id IN (1,4) AND approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2";

This sort of works but when you select the user galleries category no images are displayed in the Random or Last Additions.

It would be really handy if this was a setting in the Group Manager. You could say whether a particular group's images would appear in the Random or Last Additions on the initial page but for now I would be perfectly happy with some example code that would do this.

Cheers in advance for any help you can give me.

mookoo

Hi - Is anyone able to help with this. Thanks in advance.

mookoo

Hi - Sorry to nag but is anyone able to help with this. If it's not possible then please tell me.

Thanks

Nibbler

To add a restriction based on the cid you need to join the albums table to the pictures table on aid = aid and then join the categories table on cid = category, resolving any ambiguities. Then you can use cid <> 1

mookoo

Thanks for the response.

My knowledge of SQL is virtually nill as is my knowledge of php. Can you give me the code to do this.

Also: will this change also affect the random and last uploaded sections of the user galleries as I don't want it to. I only want this restriction to affect the index page. I would have thought that I would need some sort of condition that states that if you're looking at the index page then apply these new lines of code otherwise stick with the original code. Again I would need help with the code for this in php.

Thanks again for your help

mookoo

Hi- please please can somebody help me with this.

The reason that I only want the main categories to appear in Random and Last Uploaded sections on the index page is because at some point the user images will far out number my images. This will result in the index page being swamped with user thumbnails and not mine. As explained before - I do however want the Ranom and Last Uploaded sections to appear normally when viewing user albums. I presume this will need some sort of conditional coding like "if blah blah blah then...."

I understand that I also need to put together sql queries joining tables but I have no idea how to do it. I've tried looking at the code to see how the syntax is constructed but I just can't work it out.

Please can somebody give me an idea of what the code should look like to do this.

I really want to promote my website to the local photographic community but this is holding me up.

Thanks again in advance for any assistance you can give me.

mookoo

Hi - I fixed this myself.

if ($ALBUM_SET && $CURRENT_CAT_NAME) {
                       $sql = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2";
                } else {
                       $sql = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND owner_id IN (1,4) $ALBUM_SET ORDER BY RAND() LIMIT $limit2";
                }

This if statement condition is used earlier in the Random section to determine the heading text in the Random thumbnail box. In the original if statement, the section of code after the else statement determines that the Random box heading text is just "Random". As this is only ever the case when you are viewing the index page, I was able to adapt the code and slot in the normal SQL query and my adapted Query.

Perfect!  you only see my images (owner_id 1 or 4) on the index page. If you click on the user gallery link, the random box displays user images as normal.

This only works if you block user uploads to the main categories (which is the default anyway).

I like simple solutions.