forum.easy-joomla.org

Projects/Projekte => J! 1.5.x Serie - EasyBook 2 => Thema gestartet von: marcushjortsberg am 13. 05. 2009 17:33



Titel: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 13. 05. 2009 17:33
This is a small guide to how to add avatars in the entrys and comment area!

!! Guide updated to add avatars for visitors that ar not registered or logged in !!

A little bit of work has to be done by you, but it´s a fun feature!

Let me know if it does´nt work or if i have missed anything!!

!!REQUEST FOR HELP!!

I have not been able to add a table in a nice and hidden way to the entryform and commentform, I wanted the avatar to be in the left cell of a table of one row and two columns and the entry and comment in the right cell..... I can add the table like the getUser command but the html code for the table is visible for the writer, I want it to be hidden but pasted.....really, I want the same with the username, hidden but pasted...but this works...

!!REQUEST FOR HELP!!

I have done this with Easybook 2.0rc4, Joomla 1.5.9 updated to 1.5.10.


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: DiStefano am 22. 11. 2009 20:58
Hi Marcus,

First of all let me tell you that my tennisclub is very happy with your script that enabled us to use extra smilies for registred users.

Now we are looking at the ability to have our users display an avatar with their post. I have read you tutorial in this threat but I have a question. Could you tell me what I would have to change to get the script to load the avatar not from a different file like avatar.php, but but construct it from the username itself?

In our community everybody has an avatars that is named exactly the same as their username.

So a user with username: DiStefano will have an avatar with the name: DiStefano.jpg

Only jpg's are used, but since their are like 250 users in my tennisclub it's to hard to have them all in one file. Therefore I would like to know if the script can instead of looking at avatar.php, just use the username and automatically parse .jpg after it and use that as the avatar.

I hope this is any clear and hope you can help me with this.

Greeting and again many thanks for all that you have already done!
DiStefano


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 23. 11. 2009 04:32
Thanx for the feedback!

I would like to have the time to make everything look nice as well :) Not just functionality...to make a guestbook with all the functions AND have the ability to choose what functions to have frontend and backend...in my own backen I have added the IP of the writer so that i can see if the same guest is spaming...would like to somehow integrate Easybook with, e.g, Joomlawatch, so that the IP is clickable from Easybook and is blocked in Joomlawatch...dreams...might come true!

But your request made my mind start spinning and I started the plan of solvining it!!

I have an idea that I´m going to try out within the next two weeks, I work a lot...

Thanx again for the feedback!

PS. What is the adress to your site for the tennis club? .DS

PS2. Requesting more feedback and more modifications from others!! .DS2


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: DiStefano am 23. 11. 2009 21:10
Hi

Thanks for your quick reply and ofcourse your help! I have been thinking about it too and since easy-book doesn't actively register user id's, I think there will be the biggest problem. I personally had the idea of creating a new column inwhich the username is stored of the person that makes the post. This way you only have to include a script that add the avatar by using the username that is stored with the post and then use that to call the correct image that goes with that username (ie <img="username.jpg">). Maybe this is completely idiotic thinking, but that is why I am not the coding expert :D

The website of the tennisclub is: http://www.qravel.nl

The guestbook which uses your smilie-script can be found here: http://www.qravel.nl/index.php?option=com_easybook&view=easybook&Itemid=91

Greetings,
DiStefano


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: DiStefano am 08. 12. 2009 20:33
Hi Marcushjortsberg,

I would never try to push you, but do you have any news on this already?

If not it does not matter... Just checking...

Greetings!
DiStefano



Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 08. 12. 2009 20:41
No, not yet. Sorry.

I have A LOT in my life! School, job, competing with dogs, making websites for companies and so on....

I still have the idea in my head and will deal with it soon, I got a website job just the other day and have to finish that before this (it´s for the money :P, one has got to eat).

To make you a little bit happier, I have the same idea as you!! I think it is the best way to solve it :D

You will hear from me soon!

PS. Nice site .DS


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: DiStefano am 08. 12. 2009 21:17
haha no problem! All those other things are far more important!!!!

I will wait patiently!

Thanks for the comment about our site. It gets better with small steps, but it's very fun to do!

Greetings,
DiStefano


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 10. 12. 2009 14:38
I have made a quick solution. It works for members, not visitors, I have to add some "if"´s to the code. This is only if you just have registered users...if you have alot of visitors, they wont see the avatars...

It was less work then expected.

What I did was:


  • create folder "member" in the folder "images"
  • add the line "#easybook .easy_members img.message_images {width: 90px;}" in the css file (so that the images does not get to big in the gb)
  • make a picture for each member with a maxsize, eg. 100px width(I know, it is some work involved but right now I dont have the time to fix some userupload....)
  • add the lines "<div class="easy_members"><a name="gbentry_<?php echo $entry->id; ?>"><img src="components/com_easybook/images/member/member_<?php echo $entry->gbname ?>.jpg" /></a></div>" in the default_entrys.php that are located in the folder views/easybook/tmpl/


I hope that I did´nt miss something...

I´ll get back to you with the "if"´s....



Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 10. 12. 2009 18:09
OK! I think I´m done!

I just have to wrap it up and throw you an explanation...

One moment :P


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: DiStefano am 10. 12. 2009 18:27
Hihi can't wait to try it!!!  :P


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 10. 12. 2009 18:47
Ok here we go!

Put the lines

   <?php
$user =& JFactory::getUser();
if (!$user->guest)
{ ?>
<?php echo "<tr>
      <td width='200'>" ?><?php echo JTEXT::_('Avatarname'); ?><?php echo "<span class='small'>*</span></td>
      <td><input type='text' name='avatarname' style='width:245px;' class='inputbox' value='" ?><?php echo

$this->entry->gbname; ?><?php echo "' /></td>
   </tr>"; ?>
<?php }
else { echo "

<tr>
      <td width='200'>" ?><?php echo JTEXT::_('Avatarname'); ?> <?php echo "<span class='small'>*</span></td>
      <td><input type='text' name='avatarname' style='width:245px;' class='inputbox' value='Guest' type='hidden'

readonly /></td>
   </tr>";
   } ?>

in form.php located in /components/com_easybook/views/entry/tmpl/

Put them somewhere in the table, I pasted it in the top.

----------------------------------------------

Put the lines

<?php if ($entry->avatarname==""){
echo "<div class='easy_members'><a name='gbentry_"; ?><?php echo $entry->id; ?><?php echo "'><img

src='components/com_easybook/images/member/member_Guest.jpg' /></a></div>"; ?>
<?php } ?>


<div class="easy_members"><a name="gbentry_<?php echo $entry->id; ?>"><img

src="components/com_easybook/images/member/member_<?php echo $entry->avatarname ?>.jpg" /></a></div>

in default_entrys.php in /components/com_easybook/views/easybook/tmpl/

Here I did put it under the IP-line.

----------------------------------------

I also changed the files install.sql and install.nonutf8.sql.
Added the line

`avatarname` varchar(40) NOT NULL default '',

to both files.

-------------------------------------------

Added lines

<tr>
<td width="100" align="right" class="key">
<label for="avataraname">
<?php echo JText::_( 'Avatarname' ); ?>: </label>
</td>
<td>
<input class="text_area" type="text" name="avatarname" id="avatarname" size="32" value="<?php echo

$this->entry->avatarname;?>" />
</td>
</tr>

to the file form.php in /administrator/components/com_easybook/views/entry/tmpl/

Placed them at the top in the table.

-----------------------------------------------

Placed the lines

<th width="40"><?php echo JText::_( 'Avatarname' ); ?></th>

and

<td><?php echo $row->avatarname; ?></td>

in the file default.php in /administrator/components/com_easybook/views/entry/tmpl/

placed them in the last column in the table. Make sure that you increase the colspan (i had colspan="8" and increased it to

colspan="9"), it´s just for the looks, not nessecary....

---------------------------------------------------

Put the line

var $avatarname = null;

in the file entry.php

in /administrator/components/com_easybook/tables/

---------------------------------------------------


Create the folder member in /components/com_easybook/images/

and as earlier said: you have to make a foto for every member. If you don´t modify what I have done, you have to name all

fotos member_"the users username".jpg.

I made a foto named member_Guest.jpg for visitors so that some kind of foto shows at all for them.

------------------------------------------------------

add the line

#easybook .easy_members img.message_images {width: 90px;}"

in the file easybook.css in /components/com_easybook/css/ (so that the images does not get to big in the gb)

-----------------------------------------------------------

Make a column in db with the same stats as gbname, as is

type=varchar
length= 40
I have coallition=utf8_general_ci
null=not null

I have not filled in any other fields.




I think that is about all....

OBS!!! Remember to backup your folders components/com_easybook/ and administrator/components/com_easybook and just to be

REALLY sure, your db as well before you do this..... OBS!!!

PS. I have not written this in the proper order that it should be done. To be sure of low downtime, make all changes att one

time before you transfer the files to your server .DS

GOOD LUCK!!


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 10. 12. 2009 18:55
I forgot to mention that you can ignore the first attempt!!

The entry that I made earlier today! The one I wrote around 2 pm!

See ya!


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: DiStefano am 10. 12. 2009 20:04
WOW!

It works perfectly! Two things though:

1. Now the avatarname is echod in the form.php file (step 1) as $this->entry->gbname; This will result in the default being the full name instead of the username. How would I have to change this to call the actual username?

2. If other people are planning to use this, the default_entrys.php file is located in components/com_easybook/views/easybook/tmpl

All the rest is just perfect! I works like a charm! I am going to tweak it a bit to make it look perfect in our design and will let you see the result tomorrow!

Thanks a lot!


Titel: Re: How to add avatars to guestbook - Guide! !UPDATED GUIDE!#2
Beitrag von: marcushjortsberg am 11. 12. 2009 02:16
Change

<div class="easy_members"><a name="gbentry_<?php echo $entry->id; ?>"><img src="components/com_easybook/images/member/member_<?php echo $entry->avatarname ?>.jpg" /></a></div>

to

<div class="easy_members"><a name="gbentry_<?php echo $entry->id; ?>"><img src="components/com_easybook/images/member/<?php echo $entry->avatarname ?>.jpg" /></a></div>

in default_entrys.php

and

<?php
$user =& JFactory::getUser();
if (!$user->guest)
{ ?>
<?php echo "<tr>
      <td width='200'>" ?><?php echo JTEXT::_('Avatarname'); ?><?php echo "<span class='small'>*</span></td>
      <td><input type='text' name='avatarname' style='width:245px;' class='inputbox' value='" ?><?php echo $this->entry->gbname; ?><?php echo "' /></td>
   </tr>"; ?>
<?php }
else { echo "

<tr>
      <td width='200'>" ?><?php echo JTEXT::_('Avatarname'); ?> <?php echo "<span class='small'>*</span></td>
      <td><input type='text' name='avatarname' style='width:245px;' class='inputbox' value='Guest' type='hidden' readonly /></td>
   </tr>";
   } ?>

to

<?php
$user =& JFactory::getUser();
if (!$user->guest)
{ ?>
<?php echo "<tr>
      <td width='200'>" ?><?php echo JTEXT::_('Avatarname'); ?><?php echo "<span class='small'>*</span></td>
      <td><input type='text' name='avatarname' style='width:245px;' class='inputbox' value='" ?><?php echo $user->username; ?><?php echo "' readonly /></td>
   </tr>"; ?>
<?php }
else { echo "

<tr>
      <td width='200'>" ?><?php echo JTEXT::_('Avatarname'); ?> <?php echo "<span class='small'>*</span></td>
      <td><input type='text' name='avatarname' style='width:245px;' class='inputbox' value='Guest' type='hidden' readonly /></td>
   </tr>";
   } ?>

in form.php in /components/com_easybook/views/entry/tmpl/


and.......thats it!!

I think....I am in the middle of my nightshift....try it and tell me of it works.

Remember to change the members names of the fotos if you have started to create those...


Powered by SMF 1.1.8 | SMF © 2006, Simple Machines LLC