Hi,
I have not posted often on this topic since I didn't had any additional ideas in order to expand this MOD.
However, since yesterday, I have worked on the userpic MOD in order, for users and admins, to see a
random userpic window in the home page of their gallery. The good news is, it has been reported as complete success.
For now, no more than a single picture at the time will load (most likely like the
random image feature - already integrated as part of 4images core). If more images needs to be loaded at the time, further modifications would need to be done but would also be applied differently. That said, it would be best to remain on 1 picture at the time (randomly of course).
// Beta-TesterMy thanks goes to
Stoleti for requesting and evaluating this project.
// Affected files- index.php
- lang/english/main.php
- templates/<your_template>/home.html
// Step 1In your index.php file,
find :
//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
add
above :
//--------------------------------------
//--- Random Userpic Images ------------
//--------------------------------------
$sql = "
SELECT DISTINCT ".get_user_table_field("", "user_id"). get_user_table_field(", ", "user_name"). get_user_table_field(", ", "user_level").", userpic
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_level")." >= '".USER."'
ORDER BY RAND()
LIMIT 1
";
$result = $site_db->query($sql);
if (!$result) {
$userpic_img = $lang['no_random_userpic'];
} else {
while ($row = $site_db->fetch_array($result)) {
$userpic_img = ($config['userpic'] && @file_exists(ROOT_PATH."data/userpic/".$row['userpic']) && $user_info['user_level'] >= USER) ? "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$row['user_id']."&user_name=".$row['user_name'])."\"><img src=\"".ROOT_PATH."data/userpic/".$row['userpic']."\" width=\"".$config['userpic_width']."\" height=\"".$config['userpic_height']."\" border=\"0\"></a>" : $lang['no_random_userpic'];
$user_name = ($config['userpic'] && @file_exists(ROOT_PATH."data/userpic/".$row['userpic']) && $user_info['user_level'] >= USER) ? "<br /><a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$row['user_id']."&user_name=".$row['user_name'])."\">".$row['user_name']."</a>" : "<br /><br /><a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$row['user_id']."&user_name=".$row['user_name'])."\">".$row['user_name']."</a>";
} ###### End of while statement.
if ($user_info['user_level'] >= USER) {
$site_template->register_vars(array(
"user_name" => $user_name,
"userpic_img" => $userpic_img,
"lang_no_random_userpic" => $lang['no_random_userpic'],
"lang_random_userpic_images_title" => $lang['random_userpic_images_title']
));
} ###### End of if statement.
} ###### End of if statement.
unset ($userpic_img);
unset ($user_name);
// Step 2In your templates/<your_template>/home.html file,
add the following where you want it to appear :
<br />
<table width="450" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head1">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="head1" valign="top">{lang_random_userpic_images_title}</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="row1" align="center" valign="top">{if userpic_img}<br />{userpic_img}{endif userpic_img}{if user_name}<br />{user_name}{endif user_name}</td>
</tr>
</table>
<br />
Of course, this peace of template is simply an example. You may customize it the way you feel is right for you.
// Step 3In your lang/english/main.php file,
add
above the '?>' tag :
//-----------------------------------------------------
//--- Random userpic images ---------------------------
//-----------------------------------------------------
$lang['random_userpic_images_title'] = "Random userpic images";
$lang['no_random_userpic'] = "This user has no picture on his profile";
// Installation completeThis completes the installation of this MOD. To try it, simply go to your home page gallery and "login first" (either as a USER or ADMIN - your choice). From there, you should be able to see random userpic from your database users.
// What if they didn't uploaded a picture within their profile ?This has been thought. If users didn't uploaded a picture on their profile at all, a text will appear with their user name below (with URL of course). On either case, you will still be able to see their personal profile page.
Good luck !