• [Mod] Toplist altered 5 0 5 1
Currently:  

Author Topic: [Mod] Toplist altered  (Read 220070 times)

0 Members and 1 Guest are viewing this topic.

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« on: November 05, 2002, 10:08:02 AM »
Yesterday I started changing the code of 4 images for the first time and with succes. I altered the Toplist to show a top 10 of Most commented images.

I also added some lines to the top.php file to show the thumbnails, this last edit took me many hours since I do not have any programming skills yet, I'm a quick learner so I will be able to mange soon enough I think ;-)

Feel free to take a look and if enough people love the way I changed the toplist I might write a tutorial here.

to view the toplist: http://haunter.student.utwente.nl/Terrarevolution/galleries/top.php

Cheers,
Vraxor

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #1 on: November 05, 2002, 10:52:28 AM »
very cool!!! please tell how you did this !! i'm very intrested in your modification. Can you please email the source?

Or tell how you did this?

Dutch :)

Zou je kunnen vertellen hoe je dit hebt gedaan? Ik heb er echt heel veel belangstelling voor. Is dit ook mogelijk om op andere pagina's weer te geven?

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« Reply #2 on: November 05, 2002, 11:28:06 AM »
Hi Xippix,

I will keep this in english although I know you are Dutch too.

I have absolutely no knowledge of coding (whatever language) so I just tried and tried and succeeded. Now comes the problem I guess and that is that I use version 1.6.1 instead of 1.7

This is because I had some problems with gettig the 1.7 version to work a 100% correct. I do not yet know if the toplist code is the same or not, but we can always try. if you have some basic knowlegde of php I will just hand over some of the code I added to the top.php file and maybe you can check if this works for 1.7 too.

Cheers,
Vraxor

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #3 on: November 05, 2002, 12:06:36 PM »
Hi Vraxor,

Ok we will keep it in english  :)

I can't test it, i use 1.6 to :)

I have the same probs with 1.7.
Please send the code or share it with us.

Regards,

Bas
info@xippix.nl

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« Reply #4 on: November 05, 2002, 12:32:16 PM »
Ok,

I'm at work right now, but I will see if I can find some time later, maybe this evening to post the code. I will also write a tutorial later on in how to edit the toplist to your own liking, it isn't really hard to do and maybe one of the best pages to edit if you like to see direct results of your actions.

Cheers,
Vraxor

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #5 on: November 05, 2002, 02:15:28 PM »
ok i'm looking forward

if you have time, please mail the script to me

info@xippix.nl i can take a closer look at it.

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« Reply #6 on: November 05, 2002, 07:25:17 PM »
Here I post the Top.php code I altered. You should be able to create the needed changes in the Top template and add a new line in the English and german language main.php file.

Code: [Select]
// Rating
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_rating, i.image_votes, c.cat_name, u.user_name
        FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
        ORDER BY i.image_rating DESC, i.image_votes DESC
        LIMIT 20";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
  $top_list[$i] = $row;
  $i++;
}
$site_db->free_result();

for ($i = 1; $i <= 20; $i++) {
  if (isset($top_list[$i])) {
    $register_array['image_rating_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_rating_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_rating_user_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'])."\">".htmlspecialchars($top_list[$i]['user_name'])."</a>";
    $register_array['image_rating_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".htmlspecialchars($top_list[$i]['cat_name'])."</a>";
    $register_array['image_rating_number_'.$i] = "<b>".$top_list[$i]['image_rating']."</b> (".$top_list[$i]['image_votes']." ".$lang['votes'].")";
    $register_array['image_rating_thumb_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img src=\"data/thumbnails/".$top_list[$i]['cat_id']."/".$top_list[$i]['image_thumb_file']."\" width=\"48\" height=\"36\" border=\"0\" alt=\"\" />";
  }
  else {
    $register_array['image_rating_'.$i] = "--";
    $register_array['image_rating_user_'.$i] = "--";
    $register_array['image_rating_cat_'.$i] = "--";
    $register_array['image_rating_number_'.$i] = "--";
    $register_array['image_rating_thumb_'.$i] = "--";
  }
}

// Votes
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_rating, i.image_votes, c.cat_name, u.user_name
        FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
        ORDER BY i.image_votes DESC, i.image_name ASC
        LIMIT 20";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
  $top_list[$i] = $row;
  $i++;
}
$site_db->free_result();

for ($i = 1; $i <= 20; $i++) {
  if (isset($top_list[$i])) {
    $register_array['image_votes_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_votes_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_votes_user_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'])."\">".htmlspecialchars($top_list[$i]['user_name'])."</a>";
    $register_array['image_votes_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".htmlspecialchars($top_list[$i]['cat_name'])."</a>";
    $register_array['image_votes_number_'.$i] = "<b>".$top_list[$i]['image_rating']."</b> (".$top_list[$i]['image_votes']." ".$lang['votes'].")";
    $register_array['image_votes_thumb_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img src=\"data/thumbnails/".$top_list[$i]['cat_id']."/".$top_list[$i]['image_thumb_file']."\" width=\"48\" height=\"36\" border=\"0\" alt=\"\" />";
  }
  else {
    $register_array['image_votes_'.$i] = "--";
    $register_array['image_votes_user_'.$i] = "--";
    $register_array['image_votes_cat_'.$i] = "--";
    $register_array['image_votes_number_'.$i] = "--";
    $register_array['image_votes_thumb_'.$i] = "--";
  }
}

// Hits
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_hits, c.cat_name, u.user_name
        FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
        ORDER BY i.image_hits DESC, i.image_name ASC
        LIMIT 20";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
  $top_list[$i] = $row;
  $i++;
}
$site_db->free_result();

for ($i = 1; $i <= 20; $i++) {
  if (isset($top_list[$i])) {
    $register_array['image_hits_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_hits_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_hits_user_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'])."\">".htmlspecialchars($top_list[$i]['user_name'])."</a>";
    $register_array['image_hits_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".htmlspecialchars($top_list[$i]['cat_name'])."</a>";
    $register_array['image_hits_number_'.$i] = "<b>".$top_list[$i]['image_hits']."</b>";
    $register_array['image_hits_thumb_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img src=\"data/thumbnails/".$top_list[$i]['cat_id']."/".$top_list[$i]['image_thumb_file']."\" width=\"48\" height=\"36\" border=\"0\" alt=\"\" />";
  }
  else {
    $register_array['image_hits_'.$i] = "--";
    $register_array['image_hits_user_'.$i] = "--";
    $register_array['image_hits_cat_'.$i] = "--";
    $register_array['image_hits_number_'.$i] = "--";
    $register_array['image_hits_thumb_'.$i] = "--";
  }
}

// Downloads
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_downloads, c.cat_name, u.user_name
        FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
        ORDER BY i.image_downloads DESC, i.image_name ASC
        LIMIT 20";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
  $top_list[$i] = $row;
  $i++;
}
$site_db->free_result();

for ($i = 1; $i <= 20; $i++) {
  if (isset($top_list[$i])) {
    $register_array['image_downloads_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_downloads_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_downloads_user_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'])."\">".htmlspecialchars($top_list[$i]['user_name'])."</a>";
    $register_array['image_downloads_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".htmlspecialchars($top_list[$i]['cat_name'])."</a>";
    $register_array['image_downloads_number_'.$i] = "<b>".$top_list[$i]['image_downloads']."</b>";
    $register_array['image_downloads_thumb_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img src=\"data/thumbnails/".$top_list[$i]['cat_id']."/".$top_list[$i]['image_thumb_file']."\" width=\"48\" height=\"36\" border=\"0\" alt=\"\" />";
  }
  else {
    $register_array['image_downloads_'.$i] = "--";
    $register_array['image_downloads_user_'.$i] = "--";
    $register_array['image_downloads_cat_'.$i] = "--";
    $register_array['image_downloads_number_'.$i] = "--";
    $register_array['image_downloads_thumb_'.$i] = "--";
  }
}

// Comments
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_comments, i.image_rating, i.image_thumb_file, i.image_votes, c.cat_name, u.user_name
        FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql
        ORDER BY i.image_comments DESC, i.image_votes DESC
        LIMIT 20";
$result = $site_db->query($sql);
$top_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result)) {
  $top_list[$i] = $row;
  $i++;
}
$site_db->free_result();

for ($i = 1; $i <= 20; $i++) {
  if (isset($top_list[$i])) {
    $register_array['image_comments_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_comments_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
    $register_array['image_comments_user_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'])."\">".htmlspecialchars($top_list[$i]['user_name'])."</a>";
    $register_array['image_comments_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".htmlspecialchars($top_list[$i]['cat_name'])."</a>";
    $register_array['image_comments_number_'.$i] = "<b>".$top_list[$i]['image_comments']."</b>";
    $register_array['image_comments_thumb_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img src=\"data/thumbnails/".$top_list[$i]['cat_id']."/".$top_list[$i]['image_thumb_file']."\" width=\"48\" height=\"36\" border=\"0\" alt=\"\" />";


  }
  else {
    $register_array['image_comments_'.$i] = "--";
    $register_array['image_comments_user_'.$i] = "--";
    $register_array['image_comments_cat_'.$i] = "--";
    $register_array['image_comments_number_'.$i] = "--";
    $register_array['image_comments_thumb_'.$i] = "--";
  }
}


As you can see I copied almost the entire Top.php file and I leave it up to you to find the things I changed.

Note that this is only a part of the code from top.php and I do not know if this will be compatible with 4images 1.7 since I use 1.6.1

If there are any questions, please feel free to ask me and I will see if I can help.

Cheers,
Vraxor
http://Http://Terra.2ya.com

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #7 on: November 05, 2002, 08:00:28 PM »
well, what i need to do?

paste the code in a php document and call it top.php?

i have do that, and replace it but i get this error:

Fatal error: Call to a member function on a non-object in /home/zippie/HTML/top.php on line 8


what can i do to fix it?

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« Reply #8 on: November 05, 2002, 08:03:33 PM »
I already said that this was only part of the top.php file, so you have to past this code inside the top.php file, but only replace the code covered by the code I posted above. In this case I will send you my top.php file so that you can see what I did.

to see any difference you also need to edit the top.html template to let it use the new comments top and show the thumbnails.

Cheers,
Vraxor

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #9 on: November 05, 2002, 08:06:41 PM »
thx, i will wait for the mail. Plz send the top.html file to.

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #10 on: November 05, 2002, 09:05:55 PM »
mm i install it, but i get some errors

Code: [Select]

Parse error: parse error in /home/zippie/HTML/top.php on line 61


do you know what it is?

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« Reply #11 on: November 05, 2002, 09:07:53 PM »
This should be the line on row 61:

Code: [Select]
   $register_array['image_rating_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);

Please compare

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Yes, it's compatible with 1.7
« Reply #12 on: November 06, 2002, 02:33:44 AM »
Quote from: Vraxor
Here I post the Top.php code I altered. You should be able to create the needed changes in the Top template and add a new line in the English and german language mail.php file.

Code: [Select]
// Rating
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file,


As you can see I copied almost the entire Top.php file and I leave it up to you to find the things I changed.

Note that this is only a part of the code from top.php and I do not know if this will be compatible with 4images 1.7 since I use 1.6.1

I just tried this myself and found adding the thumbs to top.html in this manner works perfectly with 4images 1.7

Bravo!  Thanks for a super mod.  It's just so much better to have the thumbnails in the top list as it makes using the top list more appealing.  Hopefully Jan will take this up as a feature in the next release.

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Toplist altered
« Reply #13 on: November 06, 2002, 06:15:47 AM »
Thanks Chris,

I thought so too, but it would be even better if seperated thumbnail where made for the top. At this moment I use the already existing thumbnails. Those have a width of 100x*, but I resize them in html to 48x36. This only effects the way the top looks, but everybody is still loading the entire range of thumbnails.

I was at first planning to just let te toplist show more then 10 images. For example I wanted a top 50. I soon figured out that each section of top.php was seperate so it was possible to create a top 50 of best rankings and a top 100 of most hits. the only thing needed to change in order to show more images in the top is to change the following values in each section:

Code: [Select]
ORDER BY i.image_rating DESC, i.image_votes DESC
        LIMIT 20";

Code: [Select]
for ($i = 1; $i <= 20; $i++) {
  if (isset($top_list[$i])) {

If you change the value (in the example I have made a top 20, so change the 20 in both lines)

I plan about explaining the way you can edit the toplist more in a tutorial so that everybody can edit the toplist him/herself and of course it would be great if Jan implemented the changes I made in the 1.8 version.

Cheers,
Vraxor
« Last Edit: March 09, 2005, 03:05:54 AM by Chris »

Offline Jaap12

  • Full Member
  • ***
  • Posts: 108
    • View Profile
[Mod] Toplist altered
« Reply #14 on: November 06, 2002, 11:34:17 AM »
mm strange? why it doesn't work here?

i get some line errors. see post above