Author Topic: last commented image listing  (Read 88636 times)

0 Members and 1 Guest are viewing this topic.

Offline gti-the-sexy

  • Newbie
  • *
  • Posts: 33
    • View Profile
last commented image listing
« on: February 10, 2003, 11:51:47 PM »
how could we listing images that  had commented (last comment must be in the top.)

like:

last comments:
20:32 - abcd
20:30 - ghyas
19:32 - samet
19:24 - noyut
18:10 - cat
18:09 - dog
17:35 - elps
16:28 - oxxo
16:10 - bayal

with their image details links (hyperlink)
without images, only with image name and their links
for whole 4images (not category by category)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #1 on: February 11, 2003, 04:16:20 AM »
1.
Insert this code in "main" file u want it to be displayed. (index.php ;  categories.php ; details.php ; so on) (if u want use it on any pages, then try add it in /includes/page_header.php )
Code: [Select]
   $additional_sql = "";
      $table_fields = $site_db->get_table_fields(USERS_TABLE);
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
  $sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").$additional_sql."
          FROM ".COMMENTS_TABLE." c
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          ORDER BY c.comment_date DESC
 LIMIT 14";
  $result = $site_db->query($sql);
  $comment_row = array();
  while ($row = $site_db->fetch_array($result)) {
    $comment_row[] = $row;
  }
  $site_db->free_result($result);
  $num_comments = sizeof($comment_row);
  if (!$num_comments) {
    $comments_short = "<tr><td class=\"commentrow1\" colspan=\"2\">".$lang['no_comments']."</td></tr>";
  }
  else {
    $comments_short = "";
    for ($i = 0; $i < $num_comments; $i++) {
$image_id = $comment_row[$i]['image_id'];
$sql = "SELECT i.image_id, i.cat_id, i.image_name, c.cat_name
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_id = $image_id AND c.cat_id = i.cat_id";
$image_row = $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
 if (check_permission("auth_readcomment", $cat_id)){
$comment_user_name = htmlspecialchars($comment_row[$i]['comment_user_name']);
$comment_user_info = $lang['userlevel_guest'];
$comment_user_id = $comment_row[$i]['user_id'];
$user_row_comment = get_user_info($comment_user_id);
$comment_user_profile_link = "";
$comment_user_info = $lang['userlevel_guest'];
        if (!isset($comment_row[$i][$user_table_fields['user_level']]) || (isset($comment_row[$i][$user_table_fields['user_level']]) && $comment_row[$i][$user_table_fields['user_level']] == USER)) {
          $comment_user_info = $lang['userlevel_user'];
        }
        elseif ($comment_row[$i][$user_table_fields['user_level']] == ADMIN) {
          $comment_user_info = $lang['userlevel_admin'];
        }
if (isset($comment_row[$i][$user_table_fields['user_name']]) && $comment_user_id != GUEST) {
 $comment_user_name = htmlspecialchars($comment_row[$i][$user_table_fields['user_name']]);
 $comment_user_profile_link = !empty($url_show_profile) ? $site_sess->url(preg_replace("/{user_id}/", $comment_user_id, $url_show_profile)) : $site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$comment_user_id);
}
 $comment_user_profile_link = ($comment_user_profile_link) ? "<a href=\"".$comment_user_profile_link."\">".$comment_user_name."</a>" : $comment_user_name;
$site_template->register_vars(array(
 "comment_image_name" => (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id)) ? $image_row['image_name'] : "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row[$i]['image_id'].((!empty($mode)) ? "&amp;mode=".$mode : ""))."\">".$image_row['image_name']."</a>",
 "comment_cat_name" => (!check_permission("auth_viewcat", $cat_id)) ? $image_row['cat_name'] : "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\">".$image_row['cat_name']."</a>",
 "comment_user_name" => $comment_user_profile_link,
 "comment_user_info" => $comment_user_info,
 "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
 "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
 "comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),
));
$comments_short .= $site_template->parse_template("comment_short_bit");
 }
    } // end while
  } //end else
  $site_template->register_vars("comments_short", $comments_short);
  unset($comments_short);


2.
Make new template with name comment_short_bit.html.
u have chose of using those tags:
Code: [Select]
{comment_image_name}
{comment_user_name}
{comment_user_info}
{comment_headline}
{comment_text}
{comment_date}
{comment_cat_name}



3. now insert in the template that belong to the file u edited (index.php -> home.html ; categories.php -> categories.html ; so on)
Code: [Select]
{comments_short}


U can change how many comments u want to display, by changing this number:
Code: [Select]
LIMIT 14";
P.S. links to image details/category/user profile should be automaticaly disabled if u not authorized to view that page.
« Last Edit: December 21, 2008, 10:51:33 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
hi
« Reply #2 on: February 11, 2003, 05:11:58 AM »
Hi V@no do you have an example of this?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #3 on: February 11, 2003, 05:17:37 AM »
there is nothing to show, because it's all deppence on your comment_short_bit.html template.
each tag will show just a word (image name, user name/level, comment headline, comment text, date) so, it's up to u how u want it to be displayed.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
last commented image listing
« Reply #4 on: February 11, 2003, 05:48:37 AM »
Quote from: V@no
there is nothing to show, because it's all deppence on your comment_short_bit.html template.
each tag will show just a word (image name, user name/level, comment headline, comment text, date) so, it's up to u how u want it to be displayed.



Oh, Im not sure I understand exactly what this does...is this making a list of all the comments in the gallery?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #5 on: February 11, 2003, 05:53:26 AM »
well, almost. its all up to u  :wink:
right now it will show only last 14 comments
so, u can make the template that will show only last 14 comments headers with links to the image it was commented.
so, other words, this script pull out information from database about comments, users who post them, and image that was commented - into those {...} tags. and all u need is include that "information" in templates, where u want it to be displayed.

sorry if its still not clear enough... :?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
thanks
« Reply #6 on: February 11, 2003, 05:58:31 AM »
Makes sense now!...are you using this anywhere on your site?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #7 on: February 11, 2003, 06:56:49 AM »
no, I dont, but here is an example what info it can pull out the db:
http://come.no-ip.com/example.php
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

drhtm

  • Guest
last commented image listing
« Reply #8 on: February 12, 2003, 09:28:33 AM »
I'm sorry for being such a beginner, but i'm not sure how to install this...I followed your example but nothing shows up...i have over 30 comments.  any ideas...could you explain exactly where to put the codes...thanks.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #9 on: February 12, 2003, 12:32:23 PM »
Quote from: drhtm
I'm sorry for being such a beginner, but i'm not sure how to install this...I followed your example but nothing shows up...i have over 30 comments.  any ideas...could you explain exactly where to put the codes...thanks.

sry, I didnt explain it as for beginner.... :oops:
try to add this code before
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

there is someone asked how can by clicking on user, also show his comments...
with adding few lines to this code it's possible:
http://come.no-ip.com/example.php?user_id=22
will do the modification this evening  :roll:
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

drhtm

  • Guest
last commented image listing
« Reply #10 on: February 12, 2003, 05:32:57 PM »
yeah that was me!  i asked that question!

Thanks!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #11 on: February 14, 2003, 01:50:29 AM »
in the code change
Code: [Select]

  $sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").$additional_sql."
          FROM ".COMMENTS_TABLE." c
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          ORDER BY c.comment_date DESC
        LIMIT 14";
  $result = $site_db->query($sql);
  $comment_row = array();

to this:
Code: [Select]
 if (isset($HTTP_GET_VARS['user_id']) and $HTTP_GET_VARS['user_id'] != ""){
$add_where = "WHERE c.user_id IN (".$user_id.")";
  }else{
$add_where = "";
  }
  $sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").$additional_sql."
          FROM ".COMMENTS_TABLE." c
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
 ".$add_where."
          ORDER BY c.comment_date DESC
        LIMIT 14";
  $result = $site_db->query($sql);
  $comment_row = array();


after that, u can use in url: user_id=X where X is a user ID  :roll:


also, I add another (simular) MOD:
http://www.4homepages.de/forum/viewtopic.php?t=4131
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline widgit1981

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
last commented image listing
« Reply #12 on: February 14, 2003, 12:08:26 PM »
Hi

I already have the below code in my index.php file how do I add this mod?

Code: [Select]


//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');



Thanks

Steve
HighRez.com

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
last commented image listing
« Reply #13 on: February 14, 2003, 12:14:41 PM »
Quote from: V@no
Quote from: drhtm

try to add this code before
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline widgit1981

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
last commented image listing
« Reply #14 on: February 14, 2003, 12:17:47 PM »
That above code is already in my index.php.