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)WHATJust 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.
REQUIREMENTSNot 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:
<?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:
<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.phpadd anywhere before the "?>" those lines:
$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. InsertingIt'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
exampleFor example, you want to show them on the
index.php - open it and find:
require(ROOT_PATH.'includes/sessions.php');
add
below:
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.