Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Alan S on September 22, 2006, 06:10:58 PM

Title: [Tip] Adding A Biography Section To A Users Profile
Post by: Alan S on September 22, 2006, 06:10:58 PM
Been working on this for most of the day. Adds a simple biography section to a users profile. BBC code is allowed in the biography section.

File = $themedir/languages/Profile.english.php

Find

Code: [Select]
$txt[80] = 'You are not allowed to change this person's profile.';
Add on a new line

Code: [Select]
$txt['bionotice'] = 'BBC code is allowed in the biography box.';
$txt['bio'] = 'Biography';

File = $themedir/Profile.template.php

Find

Code: [Select]
// Can they add this member as a buddy?
if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
echo '
&nbsp;&nbsp;<a href="', $scripturl, '?action=buddy;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';

echo '
</td>
</tr><tr>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr><tr>
<td><b>', $txt[231], ': </b></td>
<td>', $context['member']['gender']['name'], '</td>
</tr><tr>
<td><b>', $txt[420], ':</b></td>
<td>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' &nbsp; <img src="' . $settings['images_url'] . '/bdaycake.gif" width="40" alt="" />' : ''), '</td>
</tr><tr>
<td><b>', $txt[227], ':</b></td>
<td>', $context['member']['location'], '</td>
</tr><tr>
<td><b>', $txt['local_time'], ':</b></td>
<td>', $context['member']['local_time'], '</td>
</tr><tr>';

if (!empty($modSettings['userLanguage']))
echo '
<td><b>', $txt['smf225'], ':</b></td>
<td>', $context['member']['language'], '</td>
</tr><tr>';
     echo '
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr>';


Add After

Code: [Select]
//Show the box for the biography

    echo '
<td><b>Biography:</b></td>
<td>', parse_bbc($context['member']['options']['bio']), '</td>
</tr><tr>';

 echo '
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
    </tr>';



Find

Code: [Select]
// Website details.
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>
<tr>
<td width="40%"><b>', $txt[83], ': </b><div class="smalltext">', $txt[598], '</div></td>
<td><input type="text" name="websiteTitle" size="50" value="', $context['member']['website']['title'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt[84], ': </b><div class="smalltext">', $txt[599], '</div></td>
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td>

Add After

Code: [Select]
; <td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
    </tr>

<td><b>Biography:</b> <div class="smalltext">', $txt['bionotice'], '</div></td> <td><textarea name="default_options[bio]" rows="7" cols="70">', @$context['member']['options']['bio'], '</textarea></td>

I'll most likely make it into mod form if enough people want it on there forum.

Preview Attached.

Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Zenigata on September 26, 2006, 03:45:48 PM
Nice, thank you! Does this work in 1.0 or 1.1?


Thanks
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Alan S on September 26, 2006, 04:08:49 PM
I coded it for 1.1 but it should work on 1.0 aswell since not much has changed in the profile. The search code might be a bit different but it will still work.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: mersindost on October 22, 2007, 06:41:44 PM
Thanks so Much.

This mod is working in 1.1.4  :-*

Edit: But  have problem  :(

8: Undefined index: bio
Dosya: /home/sitecom/domains/site.com/public_html/forum/Themes/default/languages/Who.turkish.php (eval?)
Satır: 297
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: metallica48423 on November 14, 2007, 10:49:43 PM
did you add it to the turkish language file as well as the english one?
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: mersindost on November 15, 2007, 05:16:50 AM
Did you mean Profile.Turkish.php?

Yes, I added codes to the Profile.Turkish.php too.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on November 17, 2007, 06:53:13 PM
I take this error:

Quote
Hoochie Coochie Man   15 Kasım 2007, 23:57:40 
 85.100.14.178     3d120b781e91d41587dd16021f82719c 
 http://www.istanblues.org/forum/index.php?action=profile;u=284 
8: Undefined index: bio
Dosya: /home/blues/public_html/forum/Themes/default/languages/Who.turkish.php (eval?)
Satır: 287
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on November 29, 2007, 05:08:55 PM
Up
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: metallica48423 on November 29, 2007, 10:47:30 PM
you added

Code: [Select]
$txt['bionotice'] = 'BBC code is allowed in the biography box.';
$txt['bio'] = 'Biography';
?

to the turkish language file?  what abut turkish-utf8 if you use UTF8?
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: marinesct on November 29, 2007, 11:39:10 PM
I had the same problem.  When you [add after] in the third step, make sure you don't have any extra ';' listed.  I found an extra ';' in my Forum Profile Information section and went in to delete it.

Since I had some confusion with how to place it, I coded it as below.  The ';' that was with the original code, should've been taken out.

Code: [Select]
// Website details.
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>
<tr>
<td width="40%"><b>', $txt[83], ': </b><div class="smalltext">', $txt[598], '</div></td>
<td><input type="text" name="websiteTitle" size="50" value="', $context['member']['website']['title'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt[84], ': </b><div class="smalltext">', $txt[599], '</div></td>
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
            </tr><tr>
<td><b>Biography:</b> <div class="smalltext">', $txt['bionotice'], '</div></td>
<td><textarea name="default_options[bio]" rows="7" cols="70">', @$context['member']['options']['bio'], '</textarea></td>
</tr>';

After I fixed the problem, I hadnt had any errors...so far.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on November 30, 2007, 07:17:01 AM
you added

Code: [Select]
$txt['bionotice'] = 'BBC code is allowed in the biography box.';
$txt['bio'] = 'Biography';
?

to the turkish language file?  what abut turkish-utf8 if you use UTF8?

Yes I added it to "languages/Profile.turkish.php"
I'm not using "UTF8"
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on November 30, 2007, 07:24:26 AM
"marinesct" your conclusion is not solved my problem.
I'm still taking this error:

Quote
http://www.istanblues.org/forum/index.php?action=profile;u=341 
8: Undefined index: bio
File: /home/blues/public_html/forum/Themes/default/languages/Who.turkish.php (eval?)
Line: 305
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on December 05, 2007, 03:30:57 PM
I take this error:

Quote
Hoochie Coochie Man   15 Kasım 2007, 23:57:40 
 85.100.14.178     3d120b781e91d41587dd16021f82719c 
 http://www.istanblues.org/forum/index.php?action=profile;u=284 
8: Undefined index: bio
Dosya: /home/blues/public_html/forum/Themes/default/languages/Who.turkish.php (eval?)
Satır: 287



I solved my promlem myself..
Alan you must change this:
Code: [Select]
<td>', parse_bbc($context['member']['options']['bio']), '</td>
To that:
Code: [Select]
<td>', @$context['member']['options']['bio'], '</td>
and there is no error message again..
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: metallica48423 on December 05, 2007, 05:05:10 PM
without parse_bbc around it, any bbcode in a bio will appear as plaintext

the @ does not fix the error, it only suppresses it.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on December 05, 2007, 05:12:04 PM
without parse_bbc around it, any bbcode in a bio will appear as plaintext

the @ does not fix the error, it only suppresses it.

Well, I don't know another way to disappear the error.
Show me if you know a way..

Beside, i don't need to BBC in bioagraphy anyway..
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Deaks on December 15, 2007, 02:08:53 PM
do you still require help?
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on December 15, 2007, 06:04:10 PM
No thanks RunicWarrior
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: badams on January 11, 2008, 01:50:51 PM
I need help.....Getting same error as Hoochie with the exception that my error states Who.english.php and not Who.turkish.php....

Error:

8: Undefined index: bio
File: /Themes/default/languages/Who.english.php (eval?)
Line: 287

Running SMF 1.1.4

Any help would be appreciated.....



Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on January 11, 2008, 01:52:42 PM
Same error..
Read this (http://www.simplemachines.org/community/index.php?topic=115547.msg1331758#msg1331758)
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: badams on January 11, 2008, 02:02:54 PM
Thanks, Hoochie.  Problem is....I want to use BBC......

I'm trying to figure out why the error is specifying Who.english.php....or in your case Who.turkish.php.  Should something be added to this file?

Sorry, I'm a newbie here.....
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: badams on January 11, 2008, 02:27:37 PM
In testing this I discovered that I only get the error on the member profiles where the biography is empty....they haven't entered anything.....I don't get the error when I view a profile where the member has entered a biography......
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Jalkson on January 11, 2008, 02:37:27 PM
Check your Who.english.php, and modifications.english.php.

Make sure this code appears.

Code: [Select]
$txt['bio'] = 'Biography';


I'm still really new to all this, but it could be your issue. :P
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: badams on January 11, 2008, 03:04:54 PM
When I tested earlier....I meant to state that I had added that line of code to Who.english.php and it took care of the error messages for those profiles that had entered text in the biography field.  However, I was still getting errors for those profiles that were not filled out by members.

Since I had already added

$txt['bio'] = 'Biography';
 
to Who.english.php....I took your suggestion and added the same code to modifications.english.php and I still get the error on those profiles where the member has not entered anything in their biography.


Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Jalkson on January 11, 2008, 03:11:41 PM
What errors are you receiving?  The same as before, but only on the empty profile bios?
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: badams on January 11, 2008, 03:18:35 PM
Same Error.......
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Jalkson on January 11, 2008, 03:42:22 PM
I'm unsure of how to fix the issue.  Seeing as how the OP is still active, it might be in your best interest to either wait and see if he answers, or PM him.

Good luck, and I'll let you know if I figure it out.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: badams on January 11, 2008, 04:09:21 PM
OK....went back to the drawing board and Alan's original code.....

In testing....I discovered that the adding the the code in Who.english.php or modifications.english.php....didn't make any difference what so ever....

Going back to the original code.....the error occurs only on those profiles where members did not fill in the biography......

I did not receive the error when a biography was present......

I feel like I'm a little bit more ahead...but back where I started....

Sounds like it needs an "If" statement somewhere....

Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on January 11, 2008, 06:05:57 PM
Guys Guys Guys :)
Listen to me dear @badams @Jalkson,

Believe me I worked on it many times. I did everything.. But still got the same error.
And finally I figured out myself (http://www.simplemachines.org/community/index.php?topic=115547.msg1331758#msg1331758).
Ok I couldn't use BBC now. But it is better taking this (http://www.simplemachines.org/community/index.php?topic=115547.msg1312619#msg1312619) error everyday.
Besides, I don't need BBC in biography :)

I wrote to Alan on MSN 3 or 4 weeks ago, and he never turn back to me. So I delete him, and this story end for me.

I am using this tip now, I'm not taking errors. So I am happy :) Thanks Alan for this tip anyway ;)
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Jalkson on January 11, 2008, 06:50:07 PM
Yes, you're fix makes it so the error doesn't show, but technically it isn't a fix.  If all the features aren't working, it isn't fixed. :P

Try pming him on the forums,  he was active today, so I'm sure you might be able to get a hold of him.


Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Hoochie Coochie Man on January 11, 2008, 07:22:40 PM
Yes, you're fix makes it so the error doesn't show, but technically it isn't a fix.  If all the features aren't working, it isn't fixed. :P
But technically it is a fix for me, because I don't need BBC tags really :) :P


Try pming him on the forums,  he was active today, so I'm sure you might be able to get a hold of him.
Maan, I give up.. :)
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: matasanos on October 02, 2008, 01:30:11 PM
I Know this topic has not been posted in for too much days..but i have found the solution thanks to woden and a old post

On the default theme Profile.template.php

Look for:

Code: [Select]
// Some more information.
echo '
</td>
</tr><tr>
<td><b>', $txt[96], ': </b></td>
<td><a href="', $context['member']['website']['url'], '" target="_blank">', $context['member']['website']['title'], '</a></td>
</tr>

and after that add this:

Code: [Select]
<tr><td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr><tr>
<td><b>About Me: </b></td>
<td>', parse_bbc (@$context['member']['options']['about_me']), '</td>
</tr><tr>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>


The look for:

Code: [Select]
// Website details.
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>
<tr>
<td width="40%"><b>', $txt[83], ': </b><div class="smalltext">', $txt[598], '</div></td>
<td><input type="text" name="websiteTitle" size="50" value="', $context['member']['website']['title'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt[84], ': </b><div class="smalltext">', $txt[599], '</div></td>
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td></tr>';

And after that add:


Code: [Select]
echo '<tr>
<td><b>About Me: </b></td>
<td><textarea name="default_options[about_me]" rows="4" cols="80" class="editor">', @$context['member']['options']['about_me'], '</textarea></td>
</tr>';

It's that easy. Please make backups before you change things. ;D
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: PHPLearner on July 05, 2009, 10:49:36 PM
I Know this topic has not been posted in for too much days..but i have found the solution thanks to woden and a old post

On the default theme Profile.template.php

Look for:

Code: [Select]
// Some more information.
echo '
</td>
</tr><tr>
<td><b>', $txt[96], ': </b></td>
<td><a href="', $context['member']['website']['url'], '" target="_blank">', $context['member']['website']['title'], '</a></td>
</tr>

and after that add this:

Code: [Select]
<tr><td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr><tr>
<td><b>About Me: </b></td>
<td>', parse_bbc (@$context['member']['options']['about_me']), '</td>
</tr><tr>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>


The look for:

Code: [Select]
// Website details.
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>
<tr>
<td width="40%"><b>', $txt[83], ': </b><div class="smalltext">', $txt[598], '</div></td>
<td><input type="text" name="websiteTitle" size="50" value="', $context['member']['website']['title'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt[84], ': </b><div class="smalltext">', $txt[599], '</div></td>
<td><input type="text" name="websiteUrl" size="50" value="', $context['member']['website']['url'], '" /></td></tr>';

And after that add:


Code: [Select]
echo '<tr>
<td><b>About Me: </b></td>
<td><textarea name="default_options[about_me]" rows="4" cols="80" class="editor">', @$context['member']['options']['about_me'], '</textarea></td>
</tr>';

It's that easy. Please make backups before you change things. ;D

Thanks A Bunch, That Took Care Of It!!!....Woo-Hoo, Used 1.1.9 Also
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: iiKiller on July 07, 2009, 01:40:06 PM
This is pretty cool ;) How about it for SMF 2.0 anytime? And this as a Mod would be wicked :D
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: JBlaze on July 26, 2009, 01:06:00 AM
This is pretty cool ;) How about it for SMF 2.0 anytime? And this as a Mod would be wicked :D

Seeing as you have already packaged it as a mod :)
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Alan S on July 30, 2009, 07:39:11 PM
Yeah i just recieved a PM from the SMF customisation team informing me that a mod had been rejected until proof could be provided that permission was given from the original coder to package it as a mod.

iKorp, iiKiller usualy permission is asked for before packaging the mod and the code is not just packaged and submitted as if it is your own work.

I would have had no problem saying you could package it if you had asked me 1st.....
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Liam. on July 31, 2009, 09:07:37 AM
Sorry :S
Suppose I was just too eager to get it out :P I added you as an author though, proves I wasn't trying to hog it :P Okay then, you'll probably say no now, but; "May I release this packaged mod please Alan?" Once again, sorry for not asking before.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Alan S on July 31, 2009, 08:12:16 PM
Lol , Its no problem.

Yes , I give my permission for IKorp to release this code as a mod.


You should link to this post when your resubmitting this mod or they will reject it again.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Joshua Dickerson on September 25, 2009, 02:10:55 PM
iKorp, did you resubmit it?
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: darrenbeige on September 25, 2009, 02:28:22 PM
I solved my promlem myself..
Alan you must change this:
Code: [Select]
<td>', parse_bbc($context['member']['options']['bio']), '</td>
To that:
Code: [Select]
<td>', @$context['member']['options']['bio'], '</td>
and there is no error message again..

If you want bbccode functionality enabled and not have the error, you need to change
Code: [Select]
<td>', parse_bbc($context['member']['options']['bio']), '</td> to
Code: [Select]
<td>', (!empty($context['member']['options']['bio']) ? parse_bbc($context['member']['options']['bio']) : '', '</td>.
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: Liam. on September 26, 2009, 01:44:57 PM
Groundup - I submitted it a while back now, twice (once after getting permission), but it's still not been accepted.

Still - how do you do this for SMF 2.0?
Title: Re: [Tip] Adding A Biography Section To A Users Profile
Post by: dkharp on January 06, 2010, 07:16:00 PM
I too would love to know this one on 2.0