[Add-on] User Age into viewprofile

Mod that adds a birthday field to the users profile, theire age are displayed beside the posts, and on there birthday they will have a greeting popup
Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

[Add-on] User Age into viewprofile

Postby Pentium_4 on Fri 18. Jul, 2003 07:37

I have just made a modification which allows to post the age of the user in his profile the basic code is in Part 3

Code: Select all
#
#-----[ OPEN FILE ]------------------------------------------
#

include/usercp_viewprofile.php

#
#-----[ FIND ]------------------------------------------
#

if ($profiledata['user_birthday']!=999999)
{
   $user_birthdate=realdate('md', $profiledata['user_birthday']);
   $i=0;
   while ($i<26)
   {
      if ($user_birthdate>=$zodiacdates[$n] & $user_birthdate<=$zodiacdates[$i+1])
      {
         $zodiac = $lang[$zodiacs[($i/2)]];
         $u_zodiac = $images[$zodiacs[($i/2)]];
         $zodiac_img = '<img src="' . $u_zodiac . '" alt="' . $zodiac . '" title="' . $zodiac . '" align="absmiddle" border="0" />';
         $i=26;
      } else
      {
         $i=$i+2;
      }
   }
}

#
#-----[ REMPLACE WITH ]------------------------------------------
#

      $this_year = create_date('Y', time(), $board_config['board_timezone']);
      $this_date = create_date('md', time(), $board_config['board_timezone']);
      if ( $profiledata['user_birthday'] != 999999 )
   {
      $poster_birthdate=realdate('md', $profiledata['user_birthday']);
      $n=0;
      while ($n<26)
      {
         if ($poster_birthdate>=$zodiacdates[$n] & $poster_birthdate<=$zodiacdates[$n+1])
         {
            $zodiac = $lang[$zodiacs[($n/2)]];
            $u_zodiac = $images[$zodiacs[($n/2)]];
            $zodiac_img = '<img src="' . $u_zodiac . '" alt="' . $zodiac . '" title="' . $zodiac . '" align="absmiddle" border="0" />';
            $n=26;
         } else
         {
            $n=$n+2;
         }
      }
      $poster_age = $this_year - realdate ('Y',$profiledata['user_birthday']);
      if ($this_date < $poster_birthdate) $poster_age--;
      $poster_age = $poster_age . '&nbsp;' . $lang['Years'];
      include($phpbb_root_path . 'includes/chinese.'.$phpEx);
      $chinese = get_chinese_year (realdate('Ymd', $profiledata['user_birthday']));
        $u_chinese = $images[$chinese];
         $chinese_img = ($chinese=='Unknown') ? '' : '<img src="' . $u_chinese . '" alt="' . $lang[$chinese] . '" title="' . $lang[$chinese] . '" align="absmiddle" border="0" />';
   } else
   {
      $zodiac = '';
      $u_zodiac = '';
      $zodiac_img = $lang['No_birthday_specify'];
      $poster_age = $lang['No_birthday_specify'];
      $chinese = '';
         $u_chinese = '';
         $chinese_img = $lang['No_birthday_specify'];
   }

#
#-----[ FIND ]------------------------------------------
#

'L_BIRTHDAY' => $lang['Birthday'],

#
#-----[ BEFORE, ADD ]------------------------------------------
#

'L_AGE' => $lang['Age'],

#
#-----[ FIND ]------------------------------------------
#

'BIRTHDAY' => ($profiledata['user_birthday']!=999999) ? realdate($lang['DATE_FORMAT'], $profiledata['user_birthday']) : $lang['No_birthday_specify'],

#
#-----[ AFTER, ADD ]------------------------------------------
#

'POSTER_AGE' => $poster_age,

#
#-----[ OPEN FILE ]------------------------------------------
#

templates/your_template/profile_view_body.tpl

#
#-----[ FIND ]------------------------------------------
#

<tr>
<td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_BIRTHDAY}:&nbsp;</span></td>
<td><b><span class="gen">{BIRTHDAY}</span></b></td>
</tr>

#
#-----[ BEFORE, ADD ]------------------------------------------
#

<tr>
<td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_AGE}:&nbsp;</span></td>
<td><b><span class="gen">{POSTER_AGE}</b></span></td>
</tr>

#
#-----[ OPEN FILE ]------------------------------------------
#

language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------
#

$lang['Age'] = 'Age';

#
#-----[ AFTER, ADD ]------------------------------------------
#

$lang['Years'] = 'years';

#
#-----[ OPEN FILE ]------------------------------------------
#

language/lang_french/lang_main.php

#
#-----[ FIND ]------------------------------------------
#

$lang['Age'] = 'Age';

#
#-----[ AFTER, ADD ]------------------------------------------
#

$lang['Years'] = 'ans';

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM


Enjoy :wink:
Last edited by Pentium_4 on Tue 19. Aug, 2003 00:05, edited 3 times in total.
User avatar
Pentium_4
Poster
Poster
 
Posts: 77
Joined: Tue 06. May, 2003 10:32
Location: 127.0.0.1

Postby Pentium_4 on Fri 18. Jul, 2003 21:00

I discovered a bug with what I gave but the modification is made on the code
I added So not specified for those who did not date of birthday :wink:
User avatar
Pentium_4
Poster
Poster
 
Posts: 77
Joined: Tue 06. May, 2003 10:32
Location: 127.0.0.1

Postby Narcosis on Sat 19. Jul, 2003 13:18

i tried it and got
Code: Select all
Fatal error: Call to undefined function: get_chinese_year() in public_html/phpBB2/includes/usercp_viewprofile.php on line 315


the problem is, you left out
Code: Select all
   include($phpbb_root_path . 'includes/chinese.'.$phpEx);

in your code. Heres a better way to do it

in usercp_viewprofile.php find
Code: Select all
if ($profiledata['user_birthday']!=999999)
{
   $user_birthdate=realdate('md', $profiledata['user_birthday']);
   $i=0;
   while ($i<26)
   {
      if ($user_birthdate>=$zodiacdates[$n] & $user_birthdate<=$zodiacdates[$i+1])
      {
         $zodiac = $lang[$zodiacs[($i/2)]];
         $u_zodiac = $images[$zodiacs[($i/2)]];
         $zodiac_img = '<img src="' . $u_zodiac . '" alt="' . $zodiac . '" title="' . $zodiac . '" align="absmiddle" border="0" />';
         $i=26;
      } else
      {
         $i=$i+2;
      }
   }
}

if ($profiledata['user_birthday']!=999999)
{
   include($phpbb_root_path . 'includes/chinese.'.$phpEx);
   $chinese = get_chinese_year (realdate('Ymd', $profiledata['user_birthday']));
   $u_chinese = $images[$chinese];
   $chinese_img = ($chinese=='Unknown') ? '' : '<img src="' . $u_chinese . '" alt="' . $lang[$chinese] . '" title="' . $lang[$chinese] . '" align="absmiddle" border="0" />';


replace with
Code: Select all
      $this_year = create_date('Y', time(), $board_config['board_timezone']);
      $this_date = create_date('md', time(), $board_config['board_timezone']);
      if ( $profiledata['user_birthday'] != 999999 )
   {
      $poster_birthdate=realdate('md', $profiledata['user_birthday']);
      $n=0;
      while ($n<26)
      {
         if ($poster_birthdate>=$zodiacdates[$n] & $poster_birthdate<=$zodiacdates[$n+1])
         {
            $zodiac = $lang[$zodiacs[($n/2)]];
            $u_zodiac = $images[$zodiacs[($n/2)]];
            $zodiac_img = '<img src="' . $u_zodiac . '" alt="' . $zodiac . '" title="' . $zodiac . '" align="absmiddle" border="0" />';
            $n=26;
         } else
         {
            $n=$n+2;
         }
      }
      $poster_age = $this_year - realdate ('Y',$profiledata['user_birthday']);
      if ($this_date < $poster_birthdate) $poster_age--;
      $poster_age = $poster_age;
   include($phpbb_root_path . 'includes/chinese.'.$phpEx);
      $chinese = get_chinese_year (realdate('Ymd', $profiledata['user_birthday']));
        $u_chinese = $images[$chinese];
         $chinese_img = ($chinese=='Unknown') ? '' : '<img src="' . $u_chinese . '" alt="' . $lang[$chinese] . '" title="' . $lang[$chinese] . '" align="absmiddle" border="0" />';
   } else
   {
      $zodiac = '';
      $u_zodiac = '';
      $zodiac_img = $lang['No_birthday_specify'];
      $poster_age = $lang['No_birthday_specify'];
      $chinese = '';
         $u_chinese = '';
         $chinese_img = $lang['No_birthday_specify'];
   }


doesnt get the error when you do that, but i still have the problem of no number appearing for the persons age
Narcosis
Poster
Poster
 
Posts: 18
Joined: Wed 16. Oct, 2002 05:38

Postby Pentium_4 on Sat 19. Jul, 2003 13:30

Really I includes nothing more on my forum his walking very well this modification and I have the same step needed to change the include really I does not understand saddened

Edit :: Arf I forgot did you install this mod completely ???
User avatar
Pentium_4
Poster
Poster
 
Posts: 77
Joined: Tue 06. May, 2003 10:32
Location: 127.0.0.1

Postby Narcosis on Sat 19. Jul, 2003 15:28

yeah i did, if you look at the original zodiac mod (part 4) it has he include chinese.php in the usercp_viewprofile.php too so im not sure why it would make sense to take it out or have it occur after the get_chinese_year function
Narcosis
Poster
Poster
 
Posts: 18
Joined: Wed 16. Oct, 2002 05:38

Postby korko on Tue 12. Aug, 2003 16:47

Pentium yaurai pas une petite erreur la ?

Code: Select all
<td><b><span class="gen">{BIRTHDAY}</b></span></td>


Inversion du /span et du /b non?

En plus fodrait revoir un truc pcq avant d'installer ton script sa marchait maintenant il me donne une erreur dans usercp_viewprofil.php a une ligne qui n'existe pas. Il me dit

Parse error: parse error, unexpected $ in /data/www/d/e/lys.ouvaton.org/html/forum/includes/usercp_viewprofile.php on line 320


Bon comme je l'ai dit, il me met a une ligne impossible. (mon code fini ligne 319)
korko
Poster
Poster
 
Posts: 18
Joined: Fri 08. Aug, 2003 19:32

Postby Pentium_4 on Tue 12. Aug, 2003 19:28

Code: Select all
<td><b><span class="gen">{BIRTHDAY}</b></span></td>


Est ce que sa marche comme sa ??? :)
Moi oui mais c'est vrai que c'est une faute que je vais corriger

par contre je commence en avoir ras le bol tous le monde a cette erreur sauf moi (peut etre que EasyPhp fout le dawaa) !
Je vais regardé :wink:

Pentium_4 :wink:
User avatar
Pentium_4
Poster
Poster
 
Posts: 77
Joined: Tue 06. May, 2003 10:32
Location: 127.0.0.1

Postby korko on Tue 12. Aug, 2003 20:25

ba regarde pcq moi impossible de revenir a mon fichier non buggué :/ c'est dommage franchement c'était une bonne idée. Surtout le 'ans' :)
korko
Poster
Poster
 
Posts: 18
Joined: Fri 08. Aug, 2003 19:32

Next

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 0 guests

cron