Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: ccbtimewiz on September 30, 2008, 08:48:09 PM

Title: Adding birthday to profile summary
Post by: ccbtimewiz on September 30, 2008, 08:48:09 PM
The following hack will put a birthday field on your profile summary. SMF by default does not do this, so this is how you do it.

Example:
(http://i33.tinypic.com/6hjkhc.png)

For SMF 2.0 BETA 4

Open ./Themes/default/Profile.template.php

Find:
if (!isset($context['disabled_fields']['gender']))
echo '
<tr>
<td><b>', $txt['gender'], ': </b></td>
<td>', $context['member']['gender']['name'], '</td>
</tr>';


Add after:
list ($year, $month, $day) = explode('-', $context['member']['birth_date']);
$bday = $day == '00' ? '' : ($txt['months_titles'][(int) $month] . ' ' . $day . ($year != '0000' ? ', ' . $year : ''));

if( !empty( $bday ) ) {
echo '
<tr>
<td><b>Birthday: </b></td>
<td>', $bday, '</td>
</tr>'; }



For SMF 1.1.x

Open ./Themes/default/Profile.template.php

Find:
// Some more information.
echo '
<tr>
<td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td>
</tr>';


Add after:
list ($year, $month, $day) = explode('-', $context['member']['birth_date']);
$bday = $day == '00' ? '' : ($txt['months_titles'][(int) $month] . ' ' . $day . ($year != '0000' ? ', ' . $year : ''));

// Let's show it!
if( !empty( $bday ) )
{
echo '
<tr>
<td><b>Birthday: </b></td>
<td>', $bday, '</td>
</tr>';
}
Title: Re: Adding birthday to profile summary
Post by: Nathaniel on September 30, 2008, 08:55:11 PM
Nice Tip/Trick ccbtimewiz, Its great when useful tweaks require few edits. ;D
Title: Re: Adding birthday to profile summary
Post by: ccbtimewiz on October 06, 2008, 06:35:22 PM
Indeed it is, L. :D
Title: Re: Adding birthday to profile summary
Post by: GJSchaller on October 18, 2008, 05:01:14 PM
Is it possible to make this into a package?  I have several SMF installs I would like to add this to quickly & easily.  ;)

Thank you!
Title: Re: Adding birthday to profile summary
Post by: ccbtimewiz on October 18, 2008, 05:45:42 PM
Alright, I finished it as a package and uploaded it to the mod site. Awaiting validation from the customization team. :)
Title: Re: Adding birthday to profile summary
Post by: GJSchaller on October 18, 2008, 05:57:24 PM
Wonderful - thank you!
Title: Re: Adding birthday to profile summary
Post by: Costa on October 21, 2008, 04:47:21 PM
Amazing!

Works fine to me in Dilber MC

Thank you!

One question, can I translate your post and post them in the portuguese area?
Title: Re: Adding birthday to profile summary
Post by: ccbtimewiz on October 21, 2008, 04:49:53 PM
Go right ahead. Though I can speak fluent Portuguese. But if you're willing to do it for me, then be my guest.

I've already made a mod for this, so linking to the mod might be easier. It should be approved quite soon. :)
Title: Re: Adding birthday to profile summary
Post by: Costa on October 21, 2008, 05:07:53 PM
Until there the portuguese community who don't understand english can do itself

Thank you very much, you can see the topic in portuguese here (http://www.simplemachines.org/community/index.php?topic=269585.new#new)

If you want to update the language it's simple

Where you put Birthday, replace that to Data de nascimento to portuguese and brazilian

Thank you one more time

Farewell
Title: Re: Adding birthday to profile summary
Post by: Batchfiles on August 29, 2009, 01:04:12 PM
This works great in SMF 1.1.10 with just one small niggle; the date order is the wrong way round for British and European forums.
Currently it prints, month: day: year: when it should be day: month: year:

This is my attempt to rectify this and it works fine, but there may be a much better way to do it. I'm still learning!


      list ($year, $month, $day) = explode('-', $context['member']['birth_date']);
      $bday = $day == '00' ? '' :' ' . $day  . " ". ($txt['months_titles'][(int) $month] . ($year != '0000' ? ', ' . $year : ''));

      // Let's show it!
      if( !empty( $bday ) )
       {
         echo '
            <tr>
               <td><b>Birthday: </b></td>
               <td>', $bday, '</td>
            </tr>';
       }
Title: Re: Adding birthday to profile summary
Post by: dkharp on January 06, 2010, 07:28:35 PM
Can this be updated to the latest version of SMF?
Title: Re: Adding birthday to profile summary
Post by: wdlax11 on February 23, 2011, 05:30:57 PM
uh well when i use it on mine it just has : it doesnt say birthday before the name?


http://biogreengaming.com/forums.html/index.php?action=profile
Title: Re: Adding birthday to profile summary
Post by: Robert. on February 24, 2011, 06:47:09 AM
Can you please attach Profile.template.php?
Title: Re: Adding birthday to profile summary
Post by: wdlax11 on February 25, 2011, 07:16:19 AM
Here it is i didnt know how to put it in the forums

http://www.2shared.com/file/kguT1Nj9/Profiletemplate.html