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: Need help to change Random and Last Additions Thanks  (Read 2814 times)

0 Members and 1 Guest are viewing this topic.

mookoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
    • Manx Visions
Need help to change Random and Last Additions Thanks
« on: July 01, 2005, 11:26:44 pm »

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.
« Last Edit: July 16, 2005, 01:02:16 pm by GauGau »
Logged

mookoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
    • Manx Visions
Re: Need help to change Random and Last Additions Thanks
« Reply #1 on: July 09, 2005, 10:11:03 pm »

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

mookoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
    • Manx Visions
Re: Need help to change Random and Last Additions Thanks
« Reply #2 on: July 12, 2005, 09:39:52 pm »

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

Thanks
Logged

Nibbler

  • Guest
Re: Need help to change Random and Last Additions Thanks
« Reply #3 on: July 12, 2005, 11:19:32 pm »

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
Logged

mookoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
    • Manx Visions
Re: Need help to change Random and Last Additions Thanks
« Reply #4 on: July 13, 2005, 12:23:55 am »

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
Logged

mookoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
    • Manx Visions
Re: Need help to change Random and Last Additions Thanks
« Reply #5 on: July 14, 2005, 11:16:46 pm »

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.
Logged

mookoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
    • Manx Visions
Re: Need help to change Random and Last Additions Thanks
« Reply #6 on: July 16, 2005, 12:49:19 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 21 queries.