Hello!
I recently started using Coppermine and am really liking it. I installed the modpack to enable use of avatars, and so far, I've gotten them working on the comments, profile page, etc., but I was also wanting to have it shown on the front page (index.php) after the registered user logs in, so they see their name and their avatar.
How do I do this code-wise? ???
I'm a novice when it comes to PHP scripting, especially anything beyond simple theme modifications. My theme is based off of the "hardwired" coppermine theme if that helps any.
Thanks for any tips!
Same has been asked here
http://forum.coppermine-gallery.net/index.php?topic=46865.0
Probably I'll post a code sample when I have some time again
that would be awesome! It is a really cool idea.
I searched a little bit for the things you said in the other thread but i am too "php-dumb" for that. ::)
perhaps i'll have another try tomorrow, when i'm not that tired..
I'm currently working on this myself and will have something in a week.. my sites new design is totally dependent upon this feature so if I can't figure out a solution, I will pay someone to do this within a week, so check back for a solution..
I am bridge with phpbb and thats where my avatars come from, so my current ideas are:
-Re-write stramms call for the avatar as done for comments (though the code is rather confusing to me, and I'm not sure how it would be rewritten for using the logged users id as opposed to the comment author, as it pulls avatar by comment author and not user id)
-Query phpbb tables for avatar URL
-Use phpbb fetch all to get avatar - CPU killing method...
If I don't come up with something within the next 2 days I'll pay someone on DP to re-write stramms code for the avatar and post it here.. unless someone here wants to do it for compensation (sorry if that is not allowed) :P
paste following code into the theme.php you're using right before the final ?>
function loginForm($logged=1) {
global $CONFIG, $lang_loginform, $REFERER;
//if (!$CONFIG['enable_loginform']) return $loginFormHtml = "";
if (!USER_ID && $CONFIG['enable_loginform']) {
$loginFormHtml = <<<EOT
<ins>
<form action="login.php?referer=$REFERER" method="post" name="loginbox" style="margin:0; padding:0;">
<table cellpadding="0" cellspacing="3" border="0">
<tr>
<td><input type="text" class="textinput" name="username" size="10" /></td>
<td><input type="password" class="textinput" name="password" size="10" /></td>
<td><input name="submitted" type="submit" value="Login" />
<input name="remember_me" type="hidden" class="checkbox" value="1" checked="checked" /></td>
</tr>
<tr>
<td class="smallfont">$lang_loginform[user]</td>
<td class="smallfont">$lang_loginform[pass]</td>
<td></td>
</tr>
</table>
</form>
</ins>
EOT;
}
if (USER_ID) {
if ($CONFIG['enable_avatar']) {
if (AVATAR_URL !="") $avatar_url = "<a href='profile.php?op=edit_profile'><img src='".AVATAR_PATH.AVATAR_URL."' class=\"image\"></a>";
else $avatar_url=" ";
$edit_profile_form_param[] = array('textplain', $avatar_url, $lang_register_php['manage_avatar']);
if (isset($_GET['uid'])) {
$user_data = $cpg_udb->get_user_infos($_GET['uid']);
$avatar_url = $user_data['avatar_url'];
if ($avatar_url !="") $avatar_url = "<img src='".AVATAR_PATH.$avatar_url."' class=\"image\">";
}
$loginFormHtml = "<span style=\"float: right\">".$avatar_url."</span>";
} else $loginFormHtml = NULL;
$loginFormHtml .= "<div align=\"right\" class=\"smallfont\">".$lang_loginform['welcome']." <strong>".(USER_NAME)." </strong><br />";
if ($CONFIG['display_pms_status']){
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID));
list($tot_all_messages) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID)." AND showed='0'");
list($tot_new_messages) = @mysql_fetch_array($result);
mysql_free_result($result);
if ($CONFIG['pms_enabled']) {
$loginFormHtml .= "<a href='pms.php'>".$lang_loginform['pms']."</a> ".$tot_new_messages.$lang_loginform['unread_total'].$tot_all_messages." </div>";
}
}
if ($CONFIG['display_buddy_status']){
// get some buddy data
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_BUDDY']} WHERE user_id=".(USER_ID));
list($tot_all_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_BUDDY_REQ']} WHERE buddy_to=".(USER_ID));
list($tot_new_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);
if ($CONFIG['enable_buddy']){
$loginFormHtml .= "<div align=\"right\" class=\"smallfont\"><a href='buddy_manage.php'>".$lang_loginform['friends'].":</a> ".$tot_new_buddies." ".$lang_loginform['request'].", ".$lang_loginform['active']." ".$tot_all_buddies." </div>";
}
}
}
return $loginFormHtml;
}
stramm send me a paypal id you just saved me a lot of time
We need your help (http://forum.coppermine-gallery.net/index.php?topic=14227.0) *wink*
Quote from: GauGau on September 19, 2007, 08:31:27 AM
We need your help (http://forum.coppermine-gallery.net/index.php?topic=14227.0) *wink*
Man trust me, I'd be the first to donate to you guys if you took donations..
And I would definitely sponsor a cache mod ;-).. though it looks impossible..
From now on though, I'll keep track of modifications I make to coppermine and post them here
Sorry to hijack
O.K. I did this and all was good until you clicked on someones name to see their profile and it gave a error trying to send it to theme.php
???
post a link and describe what you did
well I took it down but I will put it up again real quick...lol
www.bodyarttalk.com
I posted the below code before the final ?> SO THE AVATAR will show.
Yea its back up now.... I see my avatar next to the messages.
But if I click on someones name to see thier profile It errors out.
hmm.. a testuser account would be helpful ;)
sorry I had one and deleted it had to remake it
test
test123
your problem is that the profile doesn't display anymore when this avatar feature is in the theme.php?
hmmm, seems to be some incompatibility in either theme.php, template.html or even mods in profile.php ... can't tell you 100% cause I do not know your changes
at least I can tell you that profile.php shows either some frameset code or some javascript that's not part of coppermine
have you tried to add the code to the classic theme.php and try that?
Yea, it works there, just the roll over is too confusing, people in my industry aren't very computer literate lol.
So I use this one and it's "KEWL" you know and user friendly. I will just take it out, all it does is post your ava at the top.
Is there away to maybe put users avatars that are online in the anycontent?
possible, there's already a similar thread open that asks for that... maybe I have time to bring up a quick hack soon
I'm sure I will be needing that paypal button from you before I am threw lol.
;)
http://forum.coppermine-gallery.net/index.php?topic=46865.msg225401#msg225401
Quote from: Stramm on September 18, 2007, 06:39:39 PM
paste following code into the theme.php you're using right before the final ?>
function loginForm($logged=1) {
global $CONFIG, $lang_loginform, $REFERER;
//if (!$CONFIG['enable_loginform']) return $loginFormHtml = "";
if (!USER_ID && $CONFIG['enable_loginform']) {
$loginFormHtml = <<<EOT
<ins>
<form action="login.php?referer=$REFERER" method="post" name="loginbox" style="margin:0; padding:0;">
<table cellpadding="0" cellspacing="3" border="0">
<tr>
<td><input type="text" class="textinput" name="username" size="10" /></td>
<td><input type="password" class="textinput" name="password" size="10" /></td>
<td><input name="submitted" type="submit" value="Login" />
<input name="remember_me" type="hidden" class="checkbox" value="1" checked="checked" /></td>
</tr>
<tr>
<td class="smallfont">$lang_loginform[user]</td>
<td class="smallfont">$lang_loginform[pass]</td>
<td></td>
</tr>
</table>
</form>
</ins>
EOT;
}
if (USER_ID) {
if ($CONFIG['enable_avatar']) {
if (AVATAR_URL !="") $avatar_url = "<a href='profile.php?op=edit_profile'><img src='".AVATAR_PATH.AVATAR_URL."' class=\"image\"></a>";
else $avatar_url=" ";
$edit_profile_form_param[] = array('textplain', $avatar_url, $lang_register_php['manage_avatar']);
if (isset($_GET['uid'])) {
$user_data = $cpg_udb->get_user_infos($_GET['uid']);
$avatar_url = $user_data['avatar_url'];
if ($avatar_url !="") $avatar_url = "<img src='".AVATAR_PATH.$avatar_url."' class=\"image\">";
}
$loginFormHtml = "<span style=\"float: right\">".$avatar_url."</span>";
} else $loginFormHtml = NULL;
$loginFormHtml .= "<div align=\"right\" class=\"smallfont\">".$lang_loginform['welcome']." <strong>".(USER_NAME)." </strong><br />";
if ($CONFIG['display_pms_status']){
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID));
list($tot_all_messages) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID)." AND showed='0'");
list($tot_new_messages) = @mysql_fetch_array($result);
mysql_free_result($result);
if ($CONFIG['pms_enabled']) {
$loginFormHtml .= "<a href='pms.php'>".$lang_loginform['pms']."</a> ".$tot_new_messages.$lang_loginform['unread_total'].$tot_all_messages." </div>";
}
}
if ($CONFIG['display_buddy_status']){
// get some buddy data
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_BUDDY']} WHERE user_id=".(USER_ID));
list($tot_all_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_BUDDY_REQ']} WHERE buddy_to=".(USER_ID));
list($tot_new_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);
if ($CONFIG['enable_buddy']){
$loginFormHtml .= "<div align=\"right\" class=\"smallfont\"><a href='buddy_manage.php'>".$lang_loginform['friends'].":</a> ".$tot_new_buddies." ".$lang_loginform['request'].", ".$lang_loginform['active']." ".$tot_all_buddies." </div>";
}
}
}
return $loginFormHtml;
}
works fine Stram but when we click on the use names from the user list or the online status it shows error ...else things working fine , please tell me how to fix this , i tried the above mentioned codes exactly
also plaicing avatar image using place holder possible :) , i am new to php
possible... but then you have to do a lil bit more coding
Please do it staramm actually now i got to complete my Aero theme at any cost :)
Got to get that control on avatar's positioning ..would be great if its has a place holder. once this is done lil work on my skin also will be completed
I wish i Knew php :'(
Working on a gif based theme for sick IE :) .
Stramm Hope u have read through the erron i am getting , its on reply 20...
I tried to apply this code in the theme.php (oranje theme) but actually the avatar s shown, BUT if I click on my profile i just get empty white pages.
So where can I find the login form which is already somewhere in some file? I think I need to make changes in there.
Thanks Stramm :)
solved
Why don't you tell us how you solved your issue for the benfit of others with similar issues? That's the point of a support board.
Late at night I was just too tired, sorry. Hope this is the solution, for me it worked.
remove this part from the code:
if (isset($_GET['uid'])) {
$user_data = $cpg_udb->get_user_infos($_GET['uid']);
$avatar_url = $user_data['avatar_url'];
if ($avatar_url !="") $avatar_url = "<img src='".AVATAR_PATH.$avatar_url."' class=\"image\">";
}