Customizing SMF > SMF Coding Discussion
Calendar not to display age
The Wizard:
A user preference through their look and layout preferences. I all ready have the code done for that. I just need to figure out how to make the age disapear in the calendar.
Arantor:
Awesome, that's not even what you originally asked for. And it's still not the code you posted.
While we're on the subject of you actually clarifying what it is you're wanting, are you trying to make it a user preference whether they can see anyone's ages or a user preference whether their own is shown to everyone else?
The Wizard:
I'm trying to give the users the option of showing how old they are or not.
Below is my code that solves the profile problem but it's not worth anything if your age still shows up in the Calendar.
--- Quote ---
// ./Themes/default/Profile.template.php
// Find:
// 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_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
</dt>
<dd>
<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '" 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="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '" class="input_text" />
</dd>';
// Add After:
// Bill's Age Mod - Shows option to not show your age
echo '
<dt>
<input type="hidden" name="default_options[show_age]" value="0" />
<input type="checkbox" name="default_options[show_age]" id="show_age" value="1"', !empty($context['member']['options']['show_age']) ? ' checked="checked"' : '', ' class="check" />
<strong>', $txt['show_age'], '</strong>
</dt>';
// Find:
echo '
<dt>', $txt['age'], ':</dt>
<dd>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' <img src="' . $settings['images_url'] . '/cake.png" alt="" />' : ''), '</dd>';
// Replace With:
// Bill's Age Mod - Will not show Age on Birthday if Checked
if (empty($context['member']['options']['show_age']) or $context['user']['is_admin'])
echo'
<dt>', $txt['age'], ':</dt>
<dd>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' <img src="' . $settings['images_url'] . '/cake.png" alt="" />' : ''), '</dd>';
else
echo '
<dt>', $txt['age'], ':</dt>
<dd>', $txt['not_age'], '</dd>';
--- End quote ---
--- Quote ---
/Modifications.english.php
$txt['show_age'] = 'Do Not Show My Age';
$txt['not_age'] = 'The User has chosen not to Show their Age';
--- End quote ---
The Wizard:
oh yea this works in 2.0.2
Arantor:
--- Quote ---I'm trying to give the users the option of showing how old they are or not.
--- End quote ---
If you want to put in a profile option that allows you to pick whether a user wants to hide their age, you have to do a crap load more work to make that work, because that stuff is only loaded for the current user - not for all the other users being displayed.
Why do you have to go to such lengths when they could just... not put in the year? That would deal with everything without a single code change.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version