News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Show location on posts

Started by Danny S., March 03, 2011, 12:45:47 PM

Previous topic - Next topic

Danny S.

Just like the title says. Simply show the user's location within each post.

And of course, have this able to toggle on/off like the "show gender" option.

Suki

have you tried the CountryFlags mod ? http://custom.simplemachines.org/mods/index.php?mod=417

you can easily change the countries for locations.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Danny S.

Well, it would be similar to this, but would be a default option for SMF.

But what I'm referring to is the field on the user's profile would be mirrored on their posts. So if someone put "Atlanta, GA" on their profile under the location field, it would also show on posts.

I believe vBulletin has this option as default.

Suki

well, SMF has one too,  custom profile fields are on 2.0 by default, you can build a location field with it.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.


Danny S.

I understand this has been created before and that there are workarounds.

I posted in this board because I felt it should be a default option.

It's a very easy code as I have already coded it myself from scratch without using the mod.

Arantor

Just because <other forum software> has it, doesn't make it automatically grounds for inclusion. What actual benefit to SMF does it bring? Would it be commonly used? The fact it's not heavily requested sort of suggests it's not a huge feature.

Danny S.

But that could also be said about several other features currently used. Such as "show gender on posts".

And just because it's not heavily suggested doesn't mean it's not wanted. :)

Arantor

Oh, I'm not disagreeing on that score, there's easily a ton of things that could be removed.

But ultimately, if you think it should be core, it really needs to be more than the reasons given above - but because people don't even ask about how they would do it, I really can't agree that it's in demand.

Danny S.

I see your point.

The main reason I use it is because my members typically want to meet other truck guys near them. This way it would be easier for them to schedule meets without having to go to everyone's profile.

I'm fine-tuning mine now (I didn't use the mod... I would rather code it myself since I learn better that way).

So far I have:
    * Showing location on posts
    * On/Off toggle under "Current Theme"

To come (still need to code):
    * Not viewable for guests

Mick.

Quote from: Danny S. on March 03, 2011, 03:26:27 PM

To come (still need to code):
    * Not viewable for guests

See if this works...

add before your code:
if (!$context['user']['is_guest'])

Danny S.

Thanks bluedevil!

It ended up looking like this:

if (!empty($message['member']['location']) && (!$context['user']['is_guest']))

Matthew K.

It's really not a big deal...but why if (!$context['user']['is_guest']) when if ($context['user']['is_logged']) is already constructed? is_logged is defined as !$user_info['is_guest'], so doing !$context['user']['is_guest'], really isn't necessary.
Quote from: bluedevil on March 03, 2011, 03:36:06 PM
Quote from: Danny S. on March 03, 2011, 03:26:27 PM

To come (still need to code):
    * Not viewable for guests

See if this works...

add before your code:
if (!$context['user']['is_guest'])

Matthew K.

Try this.
if (!empty($message['member']['location']) && $context['user']['is_logged'])
Quote from: Danny S. on March 03, 2011, 03:40:22 PM
Thanks bluedevil!

It ended up looking like this:

if (!empty($message['member']['location']) && (!$context['user']['is_guest']))

Danny S.

I'm still trying to learn, so I mean this in no mean way...


What's the difference?

Arantor

The difference is readability, it's easier at a glance to see that something is for logged in users rather than not for guests, it's easy to miss the ! but other than that there is no technical difference.

Matthew K.

In this case, there are no need for the extra brackets that were there either. It just added characters to the statement. Which really isn't a big deal, but when you write really long statements, the more readable they are, the better. As Arantor said, there's "technically" no difference, as the output is the same.

clothahump

I would like to see this enabled as the members on my Forum are literally all in the UK and are constantly buying, selling and swapping things.

Advertisement: