News:

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

Main Menu

How to change birthday date number (order) in profile

Started by insanik, October 25, 2017, 05:02:18 AM

Previous topic - Next topic

insanik

Hello! I've been reading this forum a lot & today I decided to register because i haven't found the answer :)

I'm using SMF 2.0.13 with SMF Default Theme - Curve

I need to display the birthday date in format DD-MM-YYYY instead of YYYY-MM-DD because most of the visitors are spanish. I've been editing Profile.Modify.php and profile.template.php.

I think that I should do something in Profile.Modify.php editing this:

'input_validate' => create_function('&$value', '
global $profile_vars, $cur_profile;

if (isset($_POST[\'bday2\'], $_POST[\'bday3\']) && $value > 0 && $_POST[\'bday2\'] > 0)
{
// Set to blank?
if ((int) $_POST[\'bday3\'] == 1 && (int) $_POST[\'bday2\'] == 1 && (int) $value == 1)
$value = \'01-01-0001\';
else
$value = checkdate($value, $_POST[\'bday2\'], $_POST[\'bday3\'] < 4 ? 4 : $_POST[\'bday3\']) ? sprintf(\'%04d-%02d-%02d\', $_POST[\'bday3\'] < 4 ? 4 : $_POST[\'bday3\'], $_POST[\'bday1\'], $_POST[\'bday2\']) : \'01-01-0001\';
}
else
$value = \'01-01-0001\';

$profile_vars[\'birthdate\'] = $value;
$cur_profile[\'birthdate\'] = $value;
return false;

Now, when a visitor edits the profile there appears the date like in the image attached (1980-01-01) but if he doesn't change it to (01-01-1980) gets the error "Wrong value type sent to the database. Date expected. (p_birthdate)". Anytime that someones changes profile image, will receive the error if he doesn't change the date again..

I don't know what to do. Hope you understood my problem, cause it was difficult to explain for me. =)



Sir Osis of Liver

Don't have time to test it, but might be simpler if you just reorder the input fields in Profile.template.php -



// Callback function for entering a birthdate!
function template_profile_birthdate()
{
global $txt, $context;

// Just show the pretty box!
echo '
<dt>
<strong>', $txt['dob'], ':</strong><br />
<span class="smalltext">', $txt['dob_day'], ' - ', $txt['dob_month'], ' - ', $txt['dob_year'], '</span>
</dt>
<dd>
<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '" class="input_text" />
<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '" class="input_text" /> -
<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '" class="input_text" /> -
</dd>';
}


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

insanik

Thank You for your answer, but that was done, and my profile pages just show the age and not the birth date.

The problem is in the edit profile page of the visitors. Birth Date is shown as YYYY-MM-DD, but if you keep it like this there appear the error page. The user needs to change it every time that wants to edit the profile to DD-MM-YYYY format. What I need is that the edit profile page show by defect the format DD-MM-YYYY of birthdate.

So: Imagine that one user wants to change profile image. Before editing a line, birthdate appears like YYYY-MM-DD. If he doesn't change it to DD-MM-YYYY he can't edit anything of the profile because he will get an error. I need that in the Forum Profile configuration page birthday shown as DD-MM-YYYY.

Thank You! :)

Sir Osis of Liver

This code -



// Callback function for entering a birthdate!
function template_profile_birthdate()
{
global $txt, $context;

// Just show the pretty box!
echo '
<dt>
<strong>', $txt['dob'], ':</strong><br />
<span class="smalltext">', $txt['dob_day'], ' - ', $txt['dob_month'], ' - ', $txt['dob_year'], '</span>
</dt>
<dd>
<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '" class="input_text" /> -
<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '" class="input_text" /> -
<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '" class="input_text" />

</dd>';
}



does this -



You have to undo changes you made to Profile.Modify.php.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

insanik

Thank You! I uploaded again the original version of Profile.Modify.php and now it works perfectly. I don't know what happened before to change the data order..
Thank You again!

Advertisement: