• [MOD] Paging for comments 5 0 5 1
Currently:  

Author Topic: [MOD] Paging for comments  (Read 144651 times)

0 Members and 1 Guest are viewing this topic.

Offline insane

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Gallery
Re: [MOD] Paging for comments
« Reply #30 on: January 29, 2006, 11:22:20 PM »
shit but the users and comments will be lost, won't they?

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
Re: [MOD] Paging for comments
« Reply #31 on: January 30, 2006, 12:22:33 AM »
users, images, categories, comments, etc stays in the database, you are replacing the code, not the data.
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 Flatermann

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: [MOD] Paging for comments
« Reply #32 on: February 12, 2006, 01:31:58 PM »
I thout to post a slight change i made on the code.
The reason for this change was that my users all  had a difrent thinking of how many comment per page they what to see. yeah i know they can user the pulldown menue but that wasnt anought LOL .
The thing i did is to put a inputfield in the users controllcenter that they can give in how many comments they want to see per page.
I thout maybe someone would be intressed in this change. Hope i dont get someone made abaut it :(

NEVER forget to backup all files and databank befor doing changes.

add this in ( includes/db_field_definitions.php )
Code: [Select]
$additional_user_fields['user_comments_perpage'] = array($lang['user_comments_perpage'], "text", 0);
in meber.php
sereach for
Code: [Select]
"lang_icq" => $lang['icq'],
insert under
Code: [Select]
"lang_comments_per_page_settings" => $lang['comments_per_page_settings'],
in you lang file main.php
sereach for
Code: [Select]
$lang['icq'] = "ICQ:";
insert under
Code: [Select]
$lang['comments_per_page_settings'] = "Comments per page:";
in member_editeprofile.html sereach for ( if you dont fid in code then ist because my class="cat2".  your could be deffernt so normalyou you can inser the code under any </tr> or above any <tr> depends on were you want to show the input field.
Code: [Select]
        <tr>
          <td class="cat2"><b>{lang_icq}</b></td>
          <td colspan="3" class="cat2"><input type="text" name="user_icq"  size="30" value="{user_icq}" class="input" /></td>
        </tr>

insert under
Code: [Select]
  <tr>
          <td class="cat2"><b>{lang_comments_per_page_settings}</b></td>
          <td colspan="3" class="cat2">
            <input type="text" name="user_comments_perpage"  size="30" value="{user_comments_perpage}" class="input" />
          </td>
        </tr>

in details.php

sereach for
Code: [Select]
$commentperpage = 5;
replace with
Code: [Select]
if ($user_info['user_level'] == GUEST) {
 $commentperpage = 5;
 }
 else {
  $commentperpage = $user_info['user_comments_perpage'];
 }

now you need to insert a new feld in tha table `4images_users` called  user_comments_perpage with a standard value 5 and Typ decimal

mabe oracle could post a easy way for users how to put in a new feld in the table.   :D :mrgreen:

Greetzzzz from Flatermann



« Last Edit: February 12, 2006, 11:01:44 PM by Flatermann »

Offline glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #33 on: February 19, 2006, 07:10:45 PM »
I have a problem here,
in my detail.php is the code:
Code: [Select]
if ($image_allow_comments == 1) {
$additional_sql = "";
  if (!empty($additional_user_fields)) {
    $table_fields = $site_db->get_table_fields(USERS_TABLE);
    foreach ($additional_user_fields as $key => $val) {
      if (isset($table_fields[$key])) {
        $additional_sql .= ", u.$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_ip, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail").get_user_table_field(", u.", "user_invisible").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").get_user_table_field(", u.", "user_homepage").get_user_table_field(", u.", "user_icq").$additional_sql."
          FROM ".COMMENTS_TABLE." c
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.image_id = $image_id
          ORDER BY c.comment_date ASC";
  $result = $site_db->query($sql);

How can i replace it with the code from here?
When i replace the code so i think its right..i cant see the avatars in the comments no more.

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
Re: [MOD] Paging for comments
« Reply #34 on: February 19, 2006, 07:17:52 PM »
Perpahs it would be best if you show the code you "think its right" as well ;)
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 glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #35 on: February 19, 2006, 07:25:12 PM »
 :D

Code: [Select]
if ($image_allow_comments == 1) {
$additional_sql = "";
  if (!empty($additional_user_fields)) {
    $table_fields = $site_db->get_table_fields(USERS_TABLE);
    foreach ($additional_user_fields as $key => $val) {
      if (isset($table_fields[$key])) {
        $additional_sql .= ", u.$key";
      }
    }
  }
 if (isset($HTTP_POST_VARS['commentsetperpage']) || isset($HTTP_GET_VARS['commentsetperpage'])) {
$commentsetperpage = (intval($HTTP_POST_VARS['commentsetperpage']) ) ? intval($HTTP_POST_VARS['commentsetperpage']) : intval($HTTP_GET_VARS['commentsetperpage']);
if ($commentsetperpage) {
   $site_sess->set_session_var("commentperpage", $commentsetperpage);
   $session_info['commentperpage'] = $commentsetperpage;
}
}

if (isset($session_info['commentperpage'])) {
$commentperpage = $session_info['commentperpage'];
}
else {
$commentperpage = 5;
}
$commentsperpage_dropdown = "\n<select name=\"commentsetperpage\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['commentsperpage'].submit() }\" class=\"select\">\n";
for($i = 1; $i <= 15; $i++) {
$setvalue = 1 * $i;
$commentsperpage_dropdown .= "<option value=\"".$setvalue."\"";
   if ($setvalue == $commentperpage) {
   $commentsperpage_dropdown .= " selected=\"selected\"";
}
$commentsperpage_dropdown .= ">";
$commentsperpage_dropdown .= $setvalue;
$commentsperpage_dropdown .= "</option>\n";
}
$commentsperpage_dropdown .= "</select>\n";

$site_template->register_vars("commentsperpage_dropdown", $commentsperpage_dropdown);
$commentsperpage_dropdown_form = $site_template->parse_template("commentsperpage_dropdown_form");
$site_template->register_vars("commentsperpage_dropdown_form", $commentsperpage_dropdown_form);

 $sql = "SELECT COUNT(image_id) AS comments
     FROM ".COMMENTS_TABLE."
     WHERE image_id = $image_id";
$result = $site_db->query_firstrow($sql);
$site_db->free_result();
$num_comments = $result['comments'];
if ($action == "postcomment") {
$page = ceil($num_comments / $commentperpage);
}
$num_rows_all = (isset($num_comments)) ? $num_comments : 0;
$link_arg = $site_sess->url(ROOT_PATH."details.php?image_id=$image_id");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $commentperpage, $num_rows_all, $link_arg, $lang['comment_stats'], "comments");
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
"paging" => $getpaging->get_paging(),
"paging_stats" => ($num_comments) ? $getpaging->get_paging_stats() : ""
));
 $additional_sql = "";
 if (!empty($additional_user_fields)) {
   $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_ip, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail").get_user_table_field(", u.", "user_invisible").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").get_user_table_field(", u.", "user_homepage").get_user_table_field(", u.", "user_icq").$additional_sql."
         FROM ".COMMENTS_TABLE." c
         LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
         WHERE c.image_id = $image_id
         ORDER BY c.comment_date DESC
         LIMIT $offset, $commentperpage";
 $result = $site_db->query($sql);

when i change the code to this..the paging for comments works great..but i cant see the avatars in the comments no more.

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
Re: [MOD] Paging for comments
« Reply #36 on: February 19, 2006, 07:33:41 PM »
remove
Code: [Select]
$additional_sql = "";
if (!empty($additional_user_fields)) {
   $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]))."'";
     }
   }
}
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 glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #37 on: February 19, 2006, 07:39:28 PM »
is doesnt help..perhaps its the second code of the details..what put my avatars away?

Here is my whole details.php without the code for the paging for comments..with this code i can see the avatars.. :)
Code: [Select]
removed
« Last Edit: February 19, 2006, 07:48:33 PM by V@no »

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
Re: [MOD] Paging for comments
« Reply #38 on: February 19, 2006, 07:47:30 PM »
1) please do not post the code from entire file, but rename the file with .txt extension (or zip it) and attach to your reply.
2) please attach the modified file, not only the original.
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 glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #39 on: February 19, 2006, 07:50:49 PM »
sorry v@no

ok here is my modified detail.php.

It works for the paging of comments..but the avatars in the comments are away.
thanks for help

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
Re: [MOD] Paging for comments
« Reply #40 on: February 19, 2006, 07:57:06 PM »
You removed different block then I showed above...yet, I just realized, that that block is actualy from this mod...
So, I've updated the step 1 of this mod, now it should work with additional fields correctly.
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 glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #41 on: February 19, 2006, 08:17:01 PM »
Thank you Vano!
It works great now!
Thank you very much!

Offline glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #42 on: February 19, 2006, 08:26:57 PM »
How can i get this for the member profile also too?

In the profile i have the link to.. comments of this user.. when i click this link i see all comments of the user on one site..

Offline glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] Paging for comments
« Reply #43 on: February 21, 2006, 09:26:58 PM »
Hello please help thanks a lot :)

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
Re: [MOD] Paging for comments
« Reply #44 on: February 22, 2006, 12:41:25 AM »
You must be using some other mod, so if you have a question about that mod, then please reply to the appropriate topic.
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)