Default Avatar?

Started by Bitwiz44, November 07, 2004, 08:54:47 AM

Previous topic - Next topic

ScoobyDan

Rather than using this method to "fake" a user's avatar, would it not make more sense to amend the registration and profile scripts, to enter a default image into the user's avatar field in the database, when they register or remove their avatar in the profile page ??? This version has the benefit that the default avatar will appear on all pages, without having to make lots of changes.

I am no PHP guru, bit I might take a look at the necessary pages, to see how easy this would be.

Daniel

Iatheia

Sorry, but how to put deafult avatar in the Profile page? ???

ScoobyDan

Quote from: ScoobyDan on November 03, 2006, 08:28:09 AM
Rather than using this method to "fake" a user's avatar, would it not make more sense to amend the registration and profile scripts, to enter a default image into the user's avatar field in the database, when they register or remove their avatar in the profile page ??? This version has the benefit that the default avatar will appear on all pages, without having to make lots of changes.

I am no PHP guru, bit I might take a look at the necessary pages, to see how easy this would be.

Daniel
A bit more on this idea...

The following SQL query can be run against your database to update everyone who doesn't have an avatar to your default one (I use a modified 'blank.gif')
UPDATE `smf_members` SET `avatar` = 'blank.gif' WHERE `smf_members`.`avatar` = '';
I hope that helps someone...

Daniel

veldfire

Does this work with 1.1 Final or 1.1.1 ?

TIA,
Veldfire

Superdaantje

yes this works fine with this new releas
Greetz
Superdaantje.nl

.
Joomlabridge.org SMF Bridge Support, Downloads and Joomla Video Tutorials

husmen73 (Gulhin)

#45
New modification for yours  ;D

This link: http://www.smfturk.net/forum/mods/otoavatar_v2_eng.zip (27.12.2006)


Thank you
-Kurumsal Kimlik Web Tasarım Hizmeti.
Gülhin Portal Sistemi hakkında yorumlarınızı bekliyorum.
SMF
Referanslar --> http://www.gulhin.com/referanslar-portfoy/
-Web Tasarımı ve Tema Tasarımı Sitesi www.gulhin.com
-TOPLU MAİL GÖNDERİMİ --> http://www.toplumailsms.com
E-Ticaret Sistemi yaptırmak mı istiyorsunuz?

RoarinRow

Very cool, works on my 1.1.1 forum   ;D

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

hoopty

Quote from: Iatheia on November 10, 2006, 07:12:23 PM
Sorry, but how to put deafult avatar in the Profile page? ???
I was wondering this myself, and seemed to have worked it out as follows:

Find this code in Profile.template.php:
// Now print the second column where the members avatar/text is shown.
echo '
<td class="windowbg" valign="middle" align="center" width="150">
', $context['member']['avatar']['image'], '<br /><br />
', $context['member']['blurb'], '
</td>
</tr>';


And replace it with this code:
// Now print the second column where the members avatar/text is shown.

if (!empty($context['member']['avatar'][image]))
echo '
<td class="windowbg" valign="middle" align="center" width="150">
', $context['member']['avatar']['image'], '<br /><br />
', $context['member']['blurb'], '
</td>
</tr>';
else
echo '
<td class="windowbg" valign="middle" align="center" width="150">
<img src="', $settings['default_theme_url'], '/images/noava.gif" alt="" /><br /><br />
', $context['member']['blurb'], '
</td>
</tr>';

Be sure to make the necessary changes to your default image.  This code assumes that the image is noava.gif located in /Themes/default/images directory.
hxxp:www.pmelforum.com [nonactive]

MalastiC

   
Good night. I have SMF 1.1.1 and with himself not to find the code this:


in index.template.php look for:

   if (!empty($context['user']['avatar']))
echo '<td valign="middle">', $context['user']['avatar']['image'], '</td>';


add after

else
echo '<td valign="middle"><img src="', $settings['images_url'], '/noava.gif" alt="" /></td>';


   
I have proven with the MOD, installs it well, but it does not work. In case he serves I use the Theme Classic.

A greeting,


veldfire

Still getting a ton of these in my error log ?

8: Undefined index: avatar_selected
File: /web/sites/roseking/corysrus.com/smf/Themes/default/languages/Profile.english.php (before sub template - eval?)
Line: 230
?action=register

KGIII

veldfire:

Hi,

I am going through the old unsolved support topics. Did you get this resolved?

My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

veldfire


matasanos

and how to do that thing (default avatar) in Dilber MC theme???

i cant find the same lines of code on it.

whitedoves

I'm using RC3 and put a default image on the profile page using the following code in the Profile.template.php file:


   if ($context['member']['avatar']['image'])
echo '', $context['member']['avatar']['image'], '';
   else
echo '<img src="', $settings['images_url'], '/noava.gif" width="140" height="160" border="0" alt="">';


I will admit I know very little php, but it seemed to work fine.


I also added the avatar in the memberslist using ',$member['avatar']['image'], ' in the following code in the Memberlist.template.php file:

   if (!empty($context['members']))
   {
   foreach ($context['members'] as $member)
echo '<tr style="text-align:center;"', empty($member['sort_letter']) ? '' : ' id="letter' . $member['sort_letter'] . '"', '>
<td class="windowbg2">', $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['text'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $member['online']['image_href'] . '" alt="' . $member['online']['text'] . '" align="middle" />' : $member['online']['label'], $context['can_send_pm'] ? '</a>' : '', '</td>
<td class="windowbg2" align="left">',$member['avatar']['image'], '</td>
<td class="windowbg" align="left">', $member['link'], '</td>
<td class="windowbg2">', $member['hide_email'] ? '' : '<a href="mailto:' . $member['email'] . '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . ' ' . $member['name'] . '" /></a>', '</td>
<td class="windowbg">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank"><img src="' . $settings['images_url'] . '/www.gif" alt="' . $member['website']['title'] . '" title="' . $member['website']['title'] . '" /></a>' : '', '</td>
<td class="windowbg" align="left">', empty($member['group']) ? $member['post_group'] : $member['group'], '</td>
<td class="windowbg" align="left">', $member['registered_date'], '</td>
<td class="windowbg2" width="15">', $member['posts'], '</td>
<td class="windowbg" width="100" align="left">', $member['posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $member['post_percent'] . '" height="15" alt="" />' : '', '</td></tr>';
   }


Obviously I added an extra column in the source file as well.

But the problem is I wanted to add a default image here as well for the members who haven't added an avatar. However you can see above the if statement is already open so I'm assuming I can't do the same as in the Profile.template, unless you can place an if statement inside an open if statement. Is this possible? and how would it look? or is there a better way to do the above?

Thank you in advance...

whitedoves

In a follow up to my post yesterday, I've displayed below the sort of thing I'm talking about; it doesn't work, but does anyone see where I've gone wrong?


   if (!empty($context['members']))
   {
   foreach ($context['members'] as $member)
echo '<tr style="text-align:center;"', empty($member['sort_letter']) ? '' : ' id="letter' . $member['sort_letter'] . '"', '>
<td class="windowbg2">', $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['text'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $member['online']['image_href'] . '" alt="' . $member['online']['text'] . '" align="middle" />' : $member['online']['label'], $context['can_send_pm'] ? '</a>' : '', '</td>

<td class="windowbg2" align="left">

   if ($member['avatar']['image'])
echo '',$member['avatar']['image'], '';
   else
echo '<img src="', $settings['images_url'], '/noava.gif" width="140" height="160" border="0" alt="">';

</td>


<td class="windowbg" align="left">', $member['link'], '</td>
<td class="windowbg2">', $member['hide_email'] ? '' : '<a href="mailto:' . $member['email'] . '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . ' ' . $member['name'] . '" /></a>', '</td>
<td class="windowbg">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank"><img src="' . $settings['images_url'] . '/www.gif" alt="' . $member['website']['title'] . '" title="' . $member['website']['title'] . '" /></a>' : '', '</td>
<td class="windowbg" align="left">', empty($member['group']) ? $member['post_group'] : $member['group'], '</td>
<td class="windowbg" align="left">', $member['registered_date'], '</td>
<td class="windowbg2" width="15">', $member['posts'], '</td>
<td class="windowbg" width="100" align="left">', $member['posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $member['post_percent'] . '" height="15" alt="" />' : '', '</td></tr>';
   }

whitedoves

Can't anyone help me above?

I've got another question anyway unrelated:

Which file in the script calls for the index.template.php?

I was thinking about having another landing page in the parent directory say index2.php instead of just index.php and have two index.template.php files one which a completely different header. All the other files I hope can remain the same with the exception of the file I'm requesting here.

Oldiesmann

index.template.php is loaded on every page of the forum. I don't remember exactly where it's loaded, but it's buried in one of the Sources files somewhere.

It would just be easier to modify the existing index.template.php file (after you upgrade to SMF 1.1.2 if you're still on 1.1 RC3) than to try to load another one in its place.
Michael Eshom
Christian Metal Fans

Bulakbol

#57
Quote from: hoopty on January 06, 2007, 05:53:21 PM
Quote from: Iatheia on November 10, 2006, 07:12:23 PM
Sorry, but how to put deafult avatar in the Profile page? ???
I was wondering this myself, and seemed to have worked it out as follows:

Find this code in Profile.template.php:
// Now print the second column where the members avatar/text is shown.
echo '
<td class="windowbg" valign="middle" align="center" width="150">
', $context['member']['avatar']['image'], '<br /><br />
', $context['member']['blurb'], '
</td>
</tr>';


And replace it with this code:
// Now print the second column where the members avatar/text is shown.

if (!empty($context['member']['avatar'][image]))
echo '
<td class="windowbg" valign="middle" align="center" width="150">
', $context['member']['avatar']['image'], '<br /><br />
', $context['member']['blurb'], '
</td>
</tr>';
else
echo '
<td class="windowbg" valign="middle" align="center" width="150">
<img src="', $settings['default_theme_url'], '/images/noava.gif" alt="" /><br /><br />
', $context['member']['blurb'], '
</td>
</tr>';

Be sure to make the necessary changes to your default image.  This code assumes that the image is noava.gif located in /Themes/default/images directory.

This works well. Thanks. How about if they deleted their avatar?
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

SMdot™

wierd... all i did was rename my sm_default.gif to blank.gif and replaced the blank.gif avatar in the Avatar Folder


doesn't do anything unless the user manually clicks no pic in there profile =P

SMdot™

Quote from: Alexandre P. on November 26, 2004, 07:48:25 PM
I just modified a little bit A.M.A.'s code to add a default avatar for guests :)  Don't know if it could had be done in an easier/mor efficace way, but it works :P

In index.template.php look for:
if (!empty($context['user']['avatar']))
echo '<td valign="middle">', $context['user']['avatar']['image'], '</td>';

add after
elseif ($context['user']['is_guest'] && file_exists($settings['images_url'], '/usernoavatar.png'))
                echo '<td valign="middle"><img src="', $settings['images_url'], '/userisguest.png" alt="" /></td>';
        elseif (file_exists($settings['images_url'], '/usernoavatar.png'))
                echo '<td valign="middle"><img src="', $settings['images_url'], '/usernoavatar.png" alt="" /></td>';


In Display.template.php look for:
// Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
<div style="overflow: auto; width: 100%;">', $message['member']['avatar']['image'], '</div><br />';

add after
                        else
                                 echo '           <div style="overflow: auto; width: 100%;"><img src="', $settings['images_url'], '/usernoavatar.png" alt="" /></div><br />';

look for
// Otherwise, show the guest's email.
else
                        echo '
<br />
<br />
<a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';

replace by
// Otherwise, show the guest's default avatar and email.
else
                        echo '           <div style="overflow: auto; width: 100%;"><img src="', $settings['images_url'], '/userisguest.png" alt="" /></div>';
                        echo '
<br />
<br />
<a href="mailto:', $message['member']['email'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt[69] . '" title="' . $txt[69] . '" border="0" />' : $txt[69]), '</a>';


Assuming that the avatar images are in your Themes\x\images folder, usernoavatar.png is default's avatar for users and userisguest.png is default's avatar for guests.

You have to do the same for each theme.


oh wait which index.template.php??? i can find the "if (!empty($context['user']['avatar'])) etc" codes at all in my forum index.template.php...

Advertisement: