forum.coppermine-gallery.net

No Support => Feature requests => Topic started by: Bruz on March 08, 2004, 07:59:30 pm

Title: [wanted] aviod same images in "new comments"
Post by: Bruz on March 08, 2004, 07:59:30 pm
Hi!

I have this problem:

(http://www.kingbruz.de/Fotos/question/question.jpg)

I want to avoid the same picture shown up that often, I just need the newest comment with one picture...
Is it possible to do so, if one picture has more than one comment?

THX in advance
Bruz
Title: [wanted] aviod same images in "new comments"
Post by: Bruz on March 11, 2004, 07:15:16 am
Is anybody else interested in this feature?

And is it possible?
Title: [wanted] aviod same images in "new comments"
Post by: Bruz on March 13, 2004, 01:40:27 pm
I really need to geht rid of multiple pictures in the 'last comments', because by now, 12 people gave their comment to one picture...
It doesn't really looks good, if there is only one picture 4 times...(see my screenshot above)

gaugau: is it possible to show a picture only once?
Title: [wanted] aviod same images in "new comments"
Post by: Joachim Müller on March 13, 2004, 01:50:43 pm
It surely is, but requires looking into it. At the moment, I'm busy to get cpg1.3.0 on the way, so I won't look into this "problem" right now. Maybe someone else is willing to do so?

GauGau
Title: [wanted] aviod same images in "new comments"
Post by: Tarique Sani on March 13, 2004, 03:01:30 pm
Open functions.inc.php somewhere around line 505 will a section like

Code: [Select]
case 'lastcom': // Last comments

in that section a bit lower down is the SQL query which you will have to modify to get unique pid - fix that query and you will have what you want....

Also IMO this is unlikely to be a main stream feature
Title: [wanted] aviod same images in "new comments"
Post by: Bruz on March 13, 2004, 03:38:02 pm
Ok, I took a look - and I managed to solve nearly everything on my own in the past - but this is a little bit to...complex for me :(

Code: [Select]
       // Meta albums
        switch($album){
        case 'lastcom': // Last comments
                if ($ALBUM_SET && $CURRENT_CAT_NAME) {
                        $album_name = $album_name = $lang_meta_album_names['lastcom'].' - '. $CURRENT_CAT_NAME;
                } else {
                        $album_name = $lang_meta_album_names['lastcom'];
                }
                $result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']}  WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $ALBUM_SET");
                $nbEnr = mysql_fetch_array($result);
                $count = $nbEnr[0];
                mysql_free_result($result);

                if($select_columns == '*'){
                        $select_columns = 'p.*';
                } else {
                        $select_columns = str_replace('pid', 'c.pid', $select_columns).', msg_id, author_id, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body, aid';
                }

                $result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit");
                $rowset = db_fetch_rowset($result);
                mysql_free_result($result);

                if ($set_caption) foreach ($rowset as $key => $row){
                        if ($row['author_id']) {
                            $user_link = '<a href ="profile.php?uid='.$row['author_id'].'">'.$row['msg_author'].'</a>';
                        } else {
                                $user_link = $row['msg_author'];
                        }
                        $msg_body = strlen($row['msg_body']) > 50 ? @substr($row['msg_body'],0,50)."...": $row['msg_body'];
                        $caption = '<span class="thumb_title">'.$user_link.'</span>'.'<span class="thumb_caption">'.localised_date($row['msg_date'], $lastcom_date_fmt).'</span>'.'<span class="thumb_caption">'.$msg_body.'</span>';
                        $rowset[$key]['caption_text'] = $caption;
                }
                return $rowset;
                break;


I really dont know how to change this to match what I want...
Title: [wanted] aviod same images in "new comments"
Post by: Tarique Sani on March 13, 2004, 03:50:24 pm
Which part is complex?

Code: [Select]
SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit

This is the query you need to modify, do something like

Code: [Select]
echo"SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit"
just before or after the db_query

This will show you the expanded / evaluated SQL copy this, Open phpMyAdmin (I presume you have one) and run tthe query there - start tweaking the query till you get one which fits what you want - paste that back into the file and you are done :)

As a bonus you get to learn more SQL than you already know.
Title: [wanted] aviod same images in "new comments"
Post by: Bruz on March 14, 2004, 01:51:42 pm
hmm... I've added
Code: [Select]
echo("$result")

right after
Code: [Select]
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit");

but this gives me only 'Resource id #35' - SQL-querys are not really my thing...
Title: [wanted] aviod same images in "new comments"
Post by: Tarique Sani on March 14, 2004, 02:14:12 pm
Read what I have ask you to do and compare it to what you have done - If you still can't figure it out then I would suggest - just wait for someone to do it for you OR hire someone to do it for you
Title: [wanted] aviod same images in "new comments"
Post by: Bruz on March 14, 2004, 02:14:59 pm
well, I did what you told me - but it just wirtes
"echo"SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit""
above my "last comments" table
Maybe I understood you wrong?
Title: [wanted] aviod same images in "new comments"
Post by: Joachim Müller on March 14, 2004, 03:13:22 pm
like Tarique said: maybe you should get someone else's help to do this - as neither Tarique nor another dev is going to give you copy'n paste-ready code for your request. If we walked you through each and every step of developing this tiny mod, we could as well do it by ourselves. Learning PHP by looking at other's code and slighty changing it is a great method - if you don't understand a step, you should consult the php documentation. It's fun to find things out step by step, give it a try.

GauGau