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

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

0 Members and 1 Guest are viewing this topic.

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
[MOD] Paging for comments
« on: May 23, 2003, 03:07:58 PM »
This MOD will add Paging to comments, that means it will display only XX number of comments per page, just like in categories.php ( u probably have seen this already: http://gallery.vano.org/7570 )
Also, this MOD fix some problem, when u have extra fields in USERS_TABLE in the database (for example if u added new fields for Yahoo ID, signature) and want display it in comments too (by default u can not show value of those fields in comments. Reference).


------------ Changes in following files: -------------
/details.php
/lang/<yourlanguage>/main.php
/templates/<yourtemplate>/details.html


------------ New template: --------------
/template/<yourtemplate>/commentsperpage_dropdown_form.html


-----------| Installation |-------------

Step 1.
Open /details.php
Find:
Code: [Select]
if ($image_allow_comments == 1) {
Insert below:
Code: [Select]
  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($table_fields[$key])) {
        $additional_sql .= ", u.$key";
      }
    }
  }

Step 1.1. added 5-27-03
Find:
Code: [Select]
       "comment_id" => $comment_row[$i]['comment_id'],Add after:
Code: [Select]
"lang_comments_per_page" => $lang['comments_per_page'],
Step 1.2 added 2009-08-12
Find:
Code: [Select]
          ORDER BY c.comment_date ASCReplace it with:
Code: [Select]
          ORDER BY c.comment_date ASC
          LIMIT $offset, $commentperpage";


Step 2.
Open /lang/<yourlanguage>/main.php
Add just before closing ?>
Code: [Select]
$lang['comment_stats'] = "Found: {total_cat_images} comment(s) on {total_pages} page(s). Displayed: comment {first_page} to {last_page}.";
$lang['comments_per_page'] = "Comments per page:";


Step 3.
Open /templates/<yourtemplate>/details.html
Find:
Code: [Select]
{if allow_comments}Add after:
Code: [Select]
<a name="comments"></a>
{if paging_stats}
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="bordercolor">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="row1" valign="middle">
{paging_stats}
</td>
<td class="row1" valign="top" align="right">
{commentsperpage_dropdown_form}
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
{endif paging_stats}
{if paging}
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="bordercolor">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="row1" valign="top">{paging}</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
{endif paging}


Step 4.
Create new template /templates/<yourtemplate>/commentsperpage_dropdown_form.html with this code:
Code: [Select]
<table border="0" cellspacing="0" cellpadding="0">
<form method="post" action="{self}#comments" name="commentsperpage">
<tr>
<td>{lang_comments_per_page}&nbsp;</td>
<td>{commentsperpage_dropdown}</td>
</tr>
</form>
</table>


Step 5.
Make sure that u have new Universal Paging Class.
This MOD will work with default paging.php, but will display
Quote
Found 5 Imag(s) on 1 page(s). Dispalayed Image 1 to 5

Step 6
For 4images v1.7.1 Apply this patch:
http://www.4homepages.de/forum/index.php?topic=7493.0
« Last Edit: August 12, 2009, 07:03:59 AM 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 Xwall

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.xwall.tk
[MOD] Paging for comments
« Reply #1 on: May 23, 2003, 10:06:32 PM »
Excellent MOD :wink:

Offline toto1

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • http://www.gifanimer.com
[MOD] Paging for comments
« Reply #2 on: May 24, 2003, 05:21:19 AM »
Veno the best  :D  :D

Offline ID25

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: [MOD] Paging for comments
« Reply #3 on: August 08, 2005, 07:51:22 PM »
What i can change to DECCENDING those comments?
At now Accending, very bad :/
users can't read new comments... need to click next, next, next....

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
Re: [MOD] Paging for comments
« Reply #4 on: August 08, 2005, 08:09:14 PM »
Hello v@no

paging system is allright but i would like to use the paging system with this MOD
http://www.4homepages.de/forum/index.php?topic=7848.30

and i would like to add this paging system here
http://www.foto-kocher.com/soldpubl.php

sincerly
vincent
Beati pauperi spiritus

4images 1.7 // My Installed Mods


Offline ID25

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: [MOD] Paging for comments
« Reply #5 on: August 14, 2005, 03:55:02 AM »
There is better thing:
Code: [Select]
for($i = 1; $i <= 20; $i++) {
$setvalue = 5 * $i;

for the paging 5,10,15,20......,95,100

Offline ID25

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: [MOD] Paging for comments
« Reply #6 on: August 15, 2005, 10:21:14 PM »
And there is small bug:
 when no comments, paging numbers i see, but "Comments per page:" for this - not shown

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 #7 on: August 15, 2005, 11:55:19 PM »
There is better thing:
Code: [Select]
for($i = 1; $i <= 20; $i++) {
$setvalue = 5 * $i;

for the paging 5,10,15,20......,95,100
Have no clue what u ment by that

And there is small bug:
 when no comments, paging numbers i see, but "Comments per page:" for this - not shown
you see paging numbers (links to page 2, 3, 4, etc) when no comments at all? and in the same time, when no comments to display it doesnt show you comments per page dropdown?
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 ID25

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: [MOD] Paging for comments
« Reply #8 on: August 16, 2005, 12:31:24 AM »
if you dont want to see number 1,2,3,4,5,6,7........1000
modify to this:
Quote
for($i = 1; $i <= 20; $i++) {
$setvalue = 5 * $i;

after this you see:
5,10,15,20,25......100

Offline ID25

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: [MOD] Paging for comments
« Reply #9 on: August 16, 2005, 12:34:49 AM »
Quote
you see paging numbers (links to page 2, 3, 4, etc) when no comments at all? and in the same time, when no comments to display it doesnt show you comments per page dropdown?

i see paging numbers (links to page 2, 3, 4, etc) when no comments at all
and not see language near this "Comments per page:"

4images 1.7

Offline Josef Florian

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: [MOD] Paging for comments
« Reply #10 on: August 21, 2005, 06:49:51 PM »
Das ist ein netter Mod! Nur wie kann man folgendes noch dazu einstellen damit immer die letzten Kommentare sichtbar sind? Also die letzte Kommentarseite des ausgewählten Bildes?
    • running v1.7.6 with MOD: SortImageAsYouLike / Cooliris Slideshow
    • with © removal
    • i have problems with:
actually no[/list]

Offline ID25

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: [MOD] Paging for comments
« Reply #11 on: August 28, 2005, 07:00:37 PM »
ex: with "Opera" this feature not working automaticaly when chosing "comments per page"...
commentsperpage_dropdown_form.html must be with button:
Code: [Select]
<table border="0" cellspacing="0" cellpadding="0">
<form method="post" action="{self}#comments" name="commentsperpage">
<tr>
<td>{lang_comments_per_page}&nbsp;</td>
<td>{commentsperpage_dropdown}</td>
      <td valign="top">
        <input type="submit" value="{lang_go}" class="button" />
      </td>
</tr>
</form>
</table>

Offline beseech

  • Full Member
  • ***
  • Posts: 150
    • View Profile
Re: [MOD] Paging for comments
« Reply #12 on: September 15, 2005, 06:33:53 PM »
i've a lil doubt ... i want install it but...i've this modified (1 step) cuz the mod (member personal pic) so i'e this

Code: [Select]
if ($image_allow_comments == 1) {
  $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").", u.userpic
          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);


if i replace for

Code: [Select]
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 ASC
         LIMIT $offset, $commentperpage";
 $result = $site_db->query($sql);

i will del the ".userpic" , so the question is :

How can i install it without del ".userpic" ???

Offline Joss

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • All about digital photography
Re: [MOD] Paging for comments
« Reply #13 on: January 03, 2006, 02:41:04 PM »
I've a problem with this MOD.

I've installed Universal Paging Class v1.1 and this MOD, but in my gallery comments looks like:

...
{if paging_stats}
Found: 19 comment(s) on 4 page(s). Displayed: comment 11 to 15.    

{endif paging_stats} {if paging}
« First page  «  1  2  [3]  4  »  Last page » Go to page:

{endif paging}
...

Is there my mistake in my code? Pls, help me and sorry for my English, I'm from Russia.


Digital Photo Gallery: http://gallery.imagemaster.ru

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 #14 on: January 03, 2006, 02:43:04 PM »
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)

 

Post your comments here