News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Adding birthday to profile summary

Started by ccbtimewiz, September 30, 2008, 08:48:09 PM

Previous topic - Next topic

ccbtimewiz

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:


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>';
}

Nathaniel

Nice Tip/Trick ccbtimewiz, Its great when useful tweaks require few edits. ;D
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

ccbtimewiz


GJSchaller

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!
Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

ccbtimewiz

Alright, I finished it as a package and uploaded it to the mod site. Awaiting validation from the customization team. :)

GJSchaller

Geoffrey J. Schaller
Knight Realms - Technical Officer
http://www.knightrealms.com/

Costa

Amazing!

Works fine to me in Dilber MC

Thank you!

One question, can I translate your post and post them in the portuguese area?
Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

ccbtimewiz

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. :)

Costa

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

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
Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

Batchfiles

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>';
       }

dkharp

Can this be updated to the latest version of SMF?

wdlax11

uh well when i use it on mine it just has : it doesnt say birthday before the name?


hxxp:biogreengaming.com/forums.html/index.php?action=profile [nonactive]

Robert.

Can you please attach Profile.template.php?

wdlax11

Here it is i didnt know how to put it in the forums

hxxp:www.2shared.com/file/kguT1Nj9/Profiletemplate.html [nonactive]

Advertisement: