Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Jerry in Dezember 20, 2004, 08:15:05 NACHMITTAGS

Titel: Showing the user's age beside thier post
Beitrag von: Jerry in Dezember 20, 2004, 08:15:05 NACHMITTAGS
Awhile back some one was looking how they could show a user's age beside their posts, I came up with this:

Open /themes/default/Display.template.php
Find // Show how many posts they have made.
Add Before // Calculate their age! Hopefully they are not too old ;)
if (!empty($message['member']['birth_date']))
{
if ($message['member']['birth_date'] != '0000-00-00')
{
list ($birth_year, $birth_month, $birth_day) = sscanf($message['member']['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$message['member'] += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}
}

// Age
if (!empty($message['member']['age']))
echo '
Age: ', $message['member']['age'], '<br />';
Thought it could be useful, but didn't think the edit was big enough to be a mod :P
Titel: Re: Showing the user's age beside thier post
Beitrag von: [Unknown] in Dezember 21, 2004, 05:14:45 VORMITTAG
// Calculate their age! Hopefully they are not too old ;)
if (!empty($message['member']['birth_date']))
{
if ($message['member']['birth_date'] != '0000-00-00')
{
list ($birth_year, $birth_month, $birth_day) = sscanf($message['member']['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$message['member'] += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}
}

// Age
if (!empty($message['member']['age']))
echo '
Age: ', $message['member']['age'], '<br />';


Personally I'd format it like that :P ;).

-[Unknown]
Titel: Re: Showing the user's age beside thier post
Beitrag von: Jerry in Dezember 23, 2004, 01:28:42 NACHMITTAGS
formatted like yours :)
Titel: Re: Showing the user's age beside thier post
Beitrag von: homeslice in Dezember 24, 2004, 02:43:35 NACHMITTAGS
I entered the code where u said to and nothing changed  ???
Titel: Re: Showing the user's age beside thier post
Beitrag von: Jerry in Dezember 24, 2004, 05:48:49 NACHMITTAGS
Make sure you change the Display template of the theme are using, it will only show the age if they have it set in thier profile ;)
Titel: Re: Showing the user's age beside thier post
Beitrag von: homeslice in Dezember 25, 2004, 01:54:31 VORMITTAG
I did that, I opened the Chatbubble theme I am using, than I editted the code like u said, and entered my own birthdate and looked at a post to see if it shows my age, and I didnt even get an Age: text anywhere

?
Titel: Re: Showing the user's age beside thier post
Beitrag von: jaijaymama in Mai 15, 2005, 01:30:07 NACHMITTAGS
How can you do this to display the member's location and date they joined the forum?
Titel: Re: Showing the user's age beside thier post
Beitrag von: A.M.A in Mai 15, 2005, 02:15:21 NACHMITTAGS
use:

', $message['member']['registered'], '

', $message['member']['location'], '
Titel: Re: Showing the user's age beside thier post
Beitrag von: Senkusha in November 29, 2005, 10:50:59 VORMITTAG
Is there a way to display the date registered only (with no time)?
Titel: Re: Showing the user's age beside thier post
Beitrag von: BrotherBrian in Dezember 10, 2006, 02:31:16 NACHMITTAGS
Zitat von: Senkusha in November 29, 2005, 10:50:59 VORMITTAG
Is there a way to display the date registered only (with no time)?

I'm also wondering if this is possible.
Titel: Re: Showing the user's age beside thier post
Beitrag von: jabop in April 10, 2008, 03:08:16 NACHMITTAGS
$txt[470] does not work for SMF 2.0 Beta 3


Needs fixed, please
Titel: Re: Showing the user's age beside thier post
Beitrag von: rsw686 in April 17, 2008, 09:15:54 VORMITTAG
Zitat von: jabop in April 10, 2008, 03:08:16 NACHMITTAGS
$txt[470] does not work for SMF 2.0 Beta 3

Replace that with $txt['not_applicable']
Titel: Re: Showing the user's age beside thier post
Beitrag von: Fiery in Juni 16, 2008, 11:21:55 NACHMITTAGS
$txt['not_applicable']  worked correct?
Titel: Re: Showing the user's age beside thier post
Beitrag von: Hoochie Coochie Man in August 31, 2008, 01:40:10 NACHMITTAGS
Thanks for the tip.
Titel: Re: Showing the user's age beside thier post
Beitrag von: NeedHelp in Oktober 23, 2008, 03:57:45 VORMITTAG
Is there a way to make it where only the Admin or mods can see the ages?
Titel: Re: Showing the user's age beside thier post
Beitrag von: Oldiesmann in Dezember 02, 2008, 08:34:47 NACHMITTAGS
Do you still need help with this NeedHelp?
Titel: Re: Showing the user's age beside thier post
Beitrag von: FlixyaFriend in Februar 05, 2009, 02:35:02 NACHMITTAGS
thanks for the useful tip.