Author Topic: [ADDON-Beta] - MY Top-Images (anywhere)  (Read 15821 times)

0 Members and 1 Guest are viewing this topic.

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
[ADDON-Beta] - MY Top-Images (anywhere)
« on: September 19, 2006, 11:05:10 PM »
Changed to *BETA*, since some users are expirience problems. I will re-check my code tomorrow,
it works for me, but maybe there are some other mod's required (i've installed to many and lost the view)



WHAT
Just for the beginning i would like to say, that this ADDON shows the 4 top-images uploaded by a user, who is currently logged in, displayed by:

- image with the best received rating
- image with the most views
- image with the most comments
- image with the most votes

For example, user "Bush" is loggin into your site, he has uploaded X images. This addon show's HIM HIS 4 best images
This ADDON is based on the "Mini Top MOD" by SSL, but you don't need to have it installed.

REQUIREMENTS
Not sure, but it should work even on a "naked" system. This ADDON is being tested only on a 4images 1.7.1 installation.

Let's go...

1. Create a file called mini_top_user.php with the following content:
Code: [Select]
<?php

define
('GET_CACHES'1);
define('ROOT_PATH''./');
$user_access get_permission();

$imgtable_width ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((
substr($config['image_table_width'], -1)) == "%") {
  
$imgtable_width .= "%";
}

 
$mini_top_user_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
 
$mini_top_user_images .= "<tr class=\"imagerow1\">\n";

 
$selection = array('rating''votes''hits''comments''downloads');
 
$selection_alt = array('votes DESC''rating DESC''name ASC''name ASC''name ASC');
 
$not_in_cat "4,6,288,234,7,319,1152"//list of categories which should not be included in top image, separated by coma (i.e. "1,2,3,7")
 #$selection_cutoff = array(' AND i.image_votes > 50', '', '', '', '');

 
$num_of_cells $config['image_cells'];
 
$num_of_cells $num_of_cells count($selection) ? count($selection) : $num_of_cells;

//echo $num_of_cells;

 
for ($cnt 0$cnt $num_of_cells$cnt++) {

 
$mini_top_user_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

#$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ($not_in_cat) ".$selection_cutoff[$cnt]."
# ORDER BY i.image_".$selection[$cnt]." DESC, i.image_".$selection_alt[$cnt]." LIMIT 0,1";

$sql "SELECT i.*".$additional_sql.", c.cat_name, u.user_name
        FROM "
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE u.user_id = " 
$user_info['user_id'] . " AND u.user_id = i.user_id AND i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ($not_in_cat) ".$selection_cutoff[$cnt]."
ORDER BY i.image_"
.$selection[$cnt]." DESC, i.image_".$selection_alt[$cnt]." LIMIT 0,1";

//AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")

 
$result $site_db->query_firstrow($sql);
 
show_image($result);
 
$site_template->register_vars("lang_mini_top_mode"$lang['mini_top_'.$selection[$cnt]]);

 
$mini_top_user_images .= $site_template->parse_template("mini_top_user_bit");
 
$mini_top_user_images .= "\n</td>\n";
}

 
$mini_top_user_images .= "</tr>\n";
 
$mini_top_user_images .= "</table>\n";

 
$site_template->register_vars(array(
  
"mini_top_user_images" => $mini_top_user_images,
  
"lang_hits" => $lang['hits'],
  
"lang_downloads" => $lang['downloads'],
  
"lang_mini_top_title" => $lang['mini_top_title']
 ));
unset(
$mini_top_user_images);

?>




upload the file into your 4images home (where the index.php is)

2. Create a file called mini_top_user_bit.html with the following content:
Code: [Select]
<table cellpadding="0" cellspacing="0">

<tr>
<td width="110" height="120" valign="middle" align="center">
{lang_mini_top_mode}

{thumbnail}

</td>
</tr>
<td align="center">

{lang_rating}: <b>{image_rating}</b><BR>
{lang_votes}: <b>{image_votes}</b> <br />
{lang_hits}: <b>{image_hits}</b> <br />
{lang_comments}: <b>{image_comments}</b>


</td>
</tr>
</table>

save it and upload it into your current template folder (templates/yourtemplate/here)

3. Open /lang/your_language/main.php

add anywhere before the "?>" those lines:
Code: [Select]
$lang['mini_top_title'] = "Mini-Top";
$lang['mini_top_rating'] = "Most Rated";
$lang['mini_top_votes'] = "Most Voted";
$lang['mini_top_comments'] = "Most Commented";
$lang['mini_top_hits'] = "Most Viewed";

save it.

Inserting

It's quite easy. Just use include(ROOT_PATH.'mini_top_user.php'); in the php-file you want them to appear, and {mini_top_user_images} in the html-file.

Thats it :)

example

For example, you want to show them on the index.php - open it and find:
Code: [Select]
require(ROOT_PATH.'includes/sessions.php');

add below:
Code: [Select]
include(ROOT_PATH.'mini_top_user.php');

save it. Now open templates/your_template/home.html and use "{mini_top_user_images}" where you want the images to appear.


Hope i didn't forgot something, publishing stuff like this isn't my favorite part, but i want to share it.





« Last Edit: September 20, 2006, 02:22:47 AM by trez »

Offline lemccoy

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • DrunkIsland
Re: [ADDON] - MY Top-Images (anywhere)
« Reply #1 on: September 19, 2006, 11:46:28 PM »
it works but I couldn't get the

Code: [Select]
Rating
# Votes
# Hits
# Comments

to come up.  I also only see three files:  highest rated, most voted, most viewed.

If a user has no images I get "file not found".  Is there anyways to make this not show up at all? 

Can an image only appear once - like the highest rated overrides the most voted if the same and goes to next picture, or doesn't show double?

Thanks!


Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [ADDON] - MY Top-Images (anywhere)
« Reply #2 on: September 20, 2006, 12:52:58 AM »
Sounds Interesting , but this really does what ??

Show the photos on top , of each member , at him own profile ??? :roll:

And a suggestion, make it optional (at control panel) using radio buttons for show / not show  :P
« Last Edit: September 20, 2006, 01:18:49 AM by Stoleti »

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: [ADDON] - MY Top-Images (anywhere)
« Reply #3 on: September 20, 2006, 02:20:50 AM »
@lemccoy:

You couldn't what exatly come up? The language tags? (mini_top_mode)?

So, the "most commented" is missing?

If a user has no images you could try use {if xxx} and {ifno xxx} in the "_bit.html" , have you installed the mod that supports these tags?

Last question, i don't know, sure the must be a solution, but someone better than me has to modify that.

@Stoleti:

I think i made it clear in the first 5 lines of my post, WHAT this addon does ;) It's exactly NOT the thing you're talking about ;)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #4 on: September 20, 2006, 02:38:23 AM »
Just tested the addon on an other 4images installation - everything works  :|

Offline lemccoy

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • DrunkIsland
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #5 on: September 20, 2006, 03:11:16 PM »
when I uncomment:

Code: [Select]
//echo $num_of_cells;
I am getting a value of 3.  This is why I can only see the first three thumbnails.  I only need three ('hits', 'comments', 'downloads') so I put them in that order and it worked out.

I also had to add to /language/main.php:

Code: [Select]
$lang['mini_top_downloads'] = "'s Most Downloaded Photo";
The reason I have the 's is because my mini_top_user_bit.html template looks like this:

Code: [Select]
<b>{user_name}{lang_mini_top_mode}</b><br />
{thumbnail}<br />
<b>{image_name}</b><br />
# Votes: <b>{image_votes}</b> <br />
# Hits: <b>{image_hits}</b> <br />
# Downloads: <b>{image_downloads}</b> <br />
# Comments: <b>{image_comments}</b>

Because I don't want guest images to be seen or bots to register 404 files, i have included these tags in my home.html and top.html:
Code: [Select]
{if user_loggedin}
{ifno is_bot}

I am still trying to figure out what to do if a user has no images.  I will try installing the mod mentioned earlier.

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #6 on: September 20, 2006, 05:08:06 PM »
can we make it show , the top 4 photos of each user and them own profiles ??

 :roll:

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #7 on: September 20, 2006, 08:01:28 PM »
thank you very much.. works good for me!

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #8 on: September 20, 2006, 11:56:26 PM »
can we make it show , the top 4 photos of each user and them own profiles ??

 :roll:

show them to te logged in user, or to the viewers?

thank you very much.. works good for me!

glad to hear that :)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #9 on: September 21, 2006, 12:03:38 AM »
can we make it show , the top 4 photos of each user and them own profiles ??

 :roll:

show them to te logged in user, or to the viewers?

thank you very much.. works good for me!

glad to hear that :)

well i think on this case to profile viewers , the top 4 photos of each user , at them on profiles :) , make all users see the photos on top of each user, and them profiles :)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #10 on: September 21, 2006, 12:05:11 AM »
for that, you shoul contact mawenzi, he made a similar mod, maybe he can combine it with this one.
Or hopefully someone post a solution here ;)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #11 on: September 21, 2006, 12:23:02 AM »
for that, you shoul contact mawenzi, he made a similar mod, maybe he can combine it with this one.
Or hopefully someone post a solution here ;)

Well i've saw a mod for latest upload photo, maybe you're right :) he can help or someone else !

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #12 on: October 01, 2006, 12:21:47 AM »
hmm, it doesn´t work. I have insert it into the meber.php and in the member_profile.html and now i see the same images at all users....

Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline CCVBE

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: [ADDON-Beta] - MY Top-Images (anywhere)
« Reply #13 on: January 26, 2008, 10:17:49 AM »
Quote
I am still trying to figure out what to do if a user has no images.  I will try installing the mod mentioned earlier.

Have you found a solution for that?