Avatar in Chat Box

e107 CMS » Forums » Miscellaneous » General Discussion << Previous thread | Next thread >>
Venus
Aug 05 2012, 12:28PM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
I have seen other Management Contant Systems have their avatar's along side their chat box message. So I'm 'attempting' as a novice to figure out if e107 chat box can have that too. This is what I've added in the main code.

<img src='".$avatar."' width='40' height='40' /></img>


And here is what it looks like in the code:

$CHATBOXSTYLE = "
<img src='".$avatar."' width='40' height='40' /></img>
<b>{USERNAME}</b>
<div class='11px'>
{MESSAGE}
</div>
<br />";


It seems to kinda work. Like I can see the outline of what the image should look like but the avatar for the user isn't identifiable. Help?
Go to top
Venus
Aug 05 2012, 10:39PM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
I pray this wasn't a toughy question.
Go to top
C6Dave
Aug 05 2012, 11:19PM
  • e107 Site administrator
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12341
Posting on a weekend when things are quiet you can't expect instant answers.

As your editing $CHATBOXSTYLE in theme.php have you tried using {AVATAR} shortcode?
Go to top
Website
Moc
Aug 06 2012, 01:06AM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3514
How did you define the avatar variable?
Go to top
Venus
Aug 06 2012, 08:17AM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
C6Dave wrote ...

Posting on a weekend when things are quiet you can't expect instant answers.

As your editing $CHATBOXSTYLE in theme.php have you tried using {AVATAR} shortcode?


*blushes* Majority of the time most have been very gracious about responding quite swiftly. Though you are right. It was the weekend and can be down time.

I did try placing the {AVATAR} shortcode in it. An it alas didn't recognize it. So I choose to use that string instead. Odd when in the code you can see the shortcode for everything else. It is perplexing.
Go to top
Venus
Aug 06 2012, 08:25AM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
Moc wrote ...

How did you define the avatar variable?


Hello Moc -- Forgive my novice response. I'm soooo not a programer when identifying terms. *hugs* I defined it in the quote above and as I stated to C6Dave writer. I tried it {AVATAR} shortcode too. An still none responsive? The two codes should work because the codes are reliable anywhere else in the php. So it is quite confusing.
Go to top
Moc
Aug 06 2012, 08:55AM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3514
Hi Ventessa,

I'm going to experiment some myself on this asap. Will get back to you if no one else has found the solution for you
Go to top
Venus
Aug 06 2012, 09:09AM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
Moc wrote ...

Hi Ventessa,

I'm going to experiment some myself on this asap. Will get back to you if no one else has found the solution for you


Thank you so much Moc. I'd be nothing without you guys here on e107. I appreciate your time and ambitions to discover this small quirk.
Go to top
Moc
Aug 06 2012, 09:17AM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3514
Thank you for asking your question and posting your replies the right way (see some of my previous replies to other topics to understand what I'm talking about) Will get back to you.
Go to top
C6Dave
Aug 06 2012, 12:08PM
  • e107 Site administrator
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12341
@Ventesa as Moc says, you can't simply use '".$avatar."' without actually defining what ".$avatar." is meant to do

To give you an example, I use this code line here: [-link-] to define a 'logout' button on my forum pages which is called by

" . $FORUM_LOGOUT_LINK . " in the forum templates (it means users can logout without having to leave the forum pages)

I'm no coder but the 'case' of you call and the syntax with the additional ' appears to be wrong for a start and should be in upper case

No doubt one of the more informed (cleverer) guys will confirm everything for you when they have a chance to take a look
Go to top
Website
septor
Aug 06 2012, 03:27PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2655
First off, as stated, you need to define $avatar in order for it to display anything. You can populate the $avatar variable using the get_user_data() function using something like:

if($user = get_user_data($id)){
   $avatar = $user["user_image"];
}


WAIT before you think that is going to work, you have not defined $id, so you're going to get no results. Since you're using putting this in the $CHATBOXSTYLE there's no simply way to gather the information from within theme.php.

I'll toy around with somethings and see what I can come up with. You're welcome (and encouraged) to dabble around yourself.
Go to top
Website
septor
Aug 06 2012, 03:47PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2655
Update
Just had time to test this, it works as advertised. You may want to adjust this to limit the size of the image, however. The line you'll want to edit is:

$cb_avatar = "<img src='".$cb_user["user_image"]."' />";


Using the sizes you provided above the line should be:

$cb_avatar = "<img src='".$cb_user["user_image"]."' style='width:40px; height:40px;
' />";


-----

Here's something I think will work (this is untested, I'm in the middle of something so I can't really mess around with installing the chatbox/etc).

This requires you to modify the code, so make sure you create a backup before you begin. Note: this is done on files from 1.0.1.

Open e107_plugins/chatbox_menu/chatbox_menu.php

Find line 189:
$cb_nick = "<a href='".e_HTTP."user.php?id.{$cb_uid}'>{$cb['user_name']}</a>";


Add this directly under:

if($cb_user = get_user_data($cb_uid))
                {
                   $cb_avatar = "<img src='".$cb_user["user_image"]."' />";
                }
                else
                {
                    $cb_avatar = "";
                }


Find line 231:

$search = array('{USERNAME}', '{TIMEDATE}', '{MESSAGE}');


Change it to:

$search = array('{USERNAME}', '{TIMEDATE}', '{MESSAGE}', '{AVATAR}');


Find line 232 (I added the // because the forums were not liking it otherwise):

//
$replace = array($cb_nick,$datestamp,($cb['cb_blocked'] ? CHATBOX_L6 : $cb_message));
//


Change it to:

//
$replace = array($cb_nick,$datestamp,($cb['cb_blocked'] ? CHATBOX_L6 : $cb_message),$cb_avatar);
//


Save and upload to the same directory listed above. You should now be able to use the {AVATAR} shortcode inside $CHATBOXSTYLE.

If you aren't comfortable making the above changes, the modified file can be found here.
[ Edited Aug 06 2012, 04:58PM ]
Go to top
Website
Venus
Aug 06 2012, 05:24PM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
Thank you everyone for your immediate response. Taking a moment out of your hectic time to help me with this. I will do my best to experiment and see if these aspects work. Then I will respond to see if I clearly was not able to succeed in this quest.

Okay here we go....::attempts::
Go to top
Venus
Aug 07 2012, 09:50AM
Registered Member #35171
Joined: Apr 13 2007, 12:47PM
Location: California
Posts: 13
IT WORKS! Thank you Septor for helping me with this. Yayayay now my role-playing community will be happy. They are all about vanity to their character images. lolol
Go to top
Moc
Aug 07 2012, 12:37PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3514
Congratulations Enjoy e107 and thanks Patrick
Go to top
septor
Aug 07 2012, 04:07PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2655
Glad I could help.
Go to top
Website
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System