Location and age not seen on SMF 1.1.1

Started by harunyam, December 23, 2006, 07:52:57 PM

Previous topic - Next topic

harunyam

Hello,

Although they are entered, age, location and gender are not seen below the name of the member as before after upgrading to 1.1.1.

Is there a mod to show these or is there an option at admin side which I missed?

Thanks,

HArun

Daniel15

#1
Edit: This code has been made into a mod, which you may find at http://custom.simplemachines.org/mods/index.php?mod=638
Hello, and welcome to the forums! :)

Now, on to your problem... The problem here is that the age, location and gender aren't shown by default. To show the gender, go into the admin panel, and go to the Current Theme section. Tick the Show gender images in message view box.
The birthday and location are a bit harder (we need to edit the template), but it isn't too hard ;). Open your Themes/default/Display.template.php file, and find:

// Show the member's gender icon?
if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '')
echo '
', $txt[231], ': ', $message['member']['gender']['image'], '<br />';


Add after:

loadLanguage('Profile');
// Show the member's birthday
if ($message['member']['birth_date'] != '')
echo '
', $txt[563], ': ', $message['member']['birth_date'], '<br />';

// Show the member's location
if ($message['member']['location'] != '')
echo '
', $txt[227], ': ', $message['member']['location'], '<br />';


Showing the member's age rather than their birthdate is a bit harder still, but can be done. Since the age isn't defined by default (it isn't passed to the template), we need to edit a source file. Open Load.php, and find:

'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false),
);


Add after:

if (!empty($profile['birthdate']) && $profile['birthdate'] !== '0001-01-01') {
list ($birth_year, $birth_month, $birth_day) = sscanf($profile['birthdate'], '%d-%d-%d');
$datearray = getdate(forum_time());
$memberContext[$user] += array(
'age' => $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1)
);
}


Then, back in Themes/default/Display.template.php, find the bit you put that displays the birthday:

// Show the member's birthday
if ($message['member']['birth_date'] != '')
echo '
', $txt[563], ': ', $message['member']['birth_date'], '<br />';


Replace it with:

// Show the member's age
if (isset($message['member']['age']))
echo '
', $txt[420], ': ', $message['member']['age'], '<br />';


If you have any further questions, please do not hesitate to ask :D
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

swatt

Hi

Wow, that's crazy! I'm a new smf-user... is it really not possible to show age and location by default? Unbelievably! I hope in next version it is possible!
swatt
----
SMF 2.0 RC1.2

Daniel15

It's not done by default, as some people don't like it being displayed next to their posts. I personally see it as irrevelant data (if I really want to see a user's location and age, I'd view their profile). The good thing about SMF is its templating system allows you to modify how things are displayed, to suit you :)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

mohoganybrwn


Daniel15

Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

babjusi

Thank u for this mod Daniel15. I will install it in my forum as well

bigfish

Daniel,

Thanks for the mod I used on one of my boards.    :)

My other board has many older gals and they do not want to see their ages.  Could modify your mod and release a version that only adds the location.  ???   8)

Many thanks.   ;D


klra

Thank you very much for this excellent mod!  :)


romanilatorino

Aren't shown by default the age, location and gender.
Why ?
I have smf 1.1.2
Language italian

Matthew Schenker

I have a silly question...

If the age, gender, and location don't have a default option for displaying them, what's the point of having members enter this information at all?

I agree with those who say administrators should have the option of whether to display this information or not.

Daniel15

QuoteIf the age, gender, and location don't have a default option for displaying them, what's the point of having members enter this information at all?
It's viewable in their profile :)

QuoteI agree with those who say administrators should have the option of whether to display this information or not.
We're already working on this for SMF 2.0 - All the fields displayed will be customisable :D
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

juvebalkan

Is it possible to display on user profiles on every post Date when they are registred ? I've seen this on phpbb forums...Any simple explination is welcome! Thanks...

And yes...one more thing. Im using SMF 1.1.13 and when i install this mod it's showing me 2 times in user profiles location and age....So it doubles everything...

wolverine32

were haveing the same problem. were trying to get the location to work. but i can't find the place were to add the code. were just wanting to add the location. i hope this is easyer to do than both. someone please say they can help. thanks i downloaded the mod but were do i install it at? thanks

Kays

To install a mod upload it to the Packages folder either using an FTP client or the Package Manager. It will then be listed in the Package Manager with a link to install it.

To add just the location, in Display.template.php of the default theme or the theme you're using, find:

// Is karma display enabled?  Total or +/-?


And above it add:

// Show location
if (!empty($message['member']['location']))
echo '
', $txt[227], ': ', $message['member']['location'], '<br />';

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

N3RVE

Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

albannach

Hi,

I'm trying to install this mod, but I can't find the code shown either below, or on the actual mod page.

I'm using the 'Babylon' theme (1.1).  Does anyone know what code I need to find, to insert the mod code ?

Using SMF 1.1.4.

Thanks for any assistance you guys can offer.

Cheers,
Chris.

greyknight17

Welcome to SMF.

Chris, did you try using this mod already? You just need to make one manual edit after you install the mod. The instruction is listed on the page and the code to look for IS in the Babylon theme (I checked).

albannach

Quote from: greyknight17 on February 14, 2008, 09:40:09 AMWelcome to SMF.

Thanks :)

Quote from: greyknight17 on February 14, 2008, 09:40:09 AMChris, did you try using this mod already? You just need to make one manual edit after you install the mod. The instruction is listed on the page and the code to look for IS in the Babylon theme (I checked).

Yeah, uploaded and installed the package, then I tried editing the themes    display.template.php    file from within SMF, copied it into notepad and done a 'find' on the code the instructions suggest to insert the mod after... was unable to find it :s

I'll try checking the actual PHP file via FTP later and hopefully find it that way.

Cheers,
Chris.

Advertisement: