Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: XBleed on May 23, 2005, 01:39:50 PM

Title: Adding users location to their posts/topics.
Post by: XBleed on May 23, 2005, 01:39:50 PM
I have searched and seen this question asked countless times.  Sometimes answered, sometimes not.
I figured I would post my solution here in the Tips and Tricks forum, since this is likely the first place to look for this addition.

Please note that I have not tried this on versions previous to 1.0.3


Open Themes/Your_Theme_Folder/Display.template.php and find:
// Show their personal text?

ABOVE that, add:

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



Edit:  I updated the code so it does not show, "Location: " if the user has not entered a location in their profile.
Title: Re: Adding users location to their posts/topics.
Post by: nokonium on June 26, 2005, 12:33:41 PM
Sorry about the 'BUMP' hope you didn't spill anything.

I used to have this and somewhere along the line it has got lost.

I have the code to display the location, but what I want is to specify what is shown if they do not have their location in their profile i.e. Hopelessly lost  ;)

Can someone point me in the right direction please?

[edit]It looks like this has replaced the code that specified the default

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


Title: Re: Adding users location to their posts/topics.
Post by: XBleed on June 26, 2005, 02:05:19 PM
Here's how I would go about this:

Open Themes/Your_Theme_Folder/languages/index.english.php and find:

$txt[227] = 'Location';

BELOW that add:

$txt[hopelost] = 'Hoplessly lost';

Now open Themes/Your_Theme_Folder/Display.template.php and find:


// Show their personal text?


ABOVE that, add:


// Show members location.
if (!empty($message['member']['location']))
echo '
', $txt[227], ': ', $message['member']['location'], '<br />
<br />';
elseif (empty($message['member']['location']))
echo '
', $txt[227], ': ', $txt[hopelost], '<br />
<br />';
Title: Re: Adding users location to their posts/topics.
Post by: nokonium on June 26, 2005, 02:28:18 PM
You've got it  :D

I can edit 'Default personal text:' in Edit Features and Options, which currently is "I haven't noticed this yet' but would like to also have default location text.

You are probably getting the impression that I'm a bit of a PNL taker, (http://www.nokonium.plus.com/black-cat/nice/transform.gif)




P.S.
PNL=Post Nutritive Liquid
Title: Re: Adding users location to their posts/topics.
Post by: XBleed on June 26, 2005, 02:32:36 PM
Ohhh, I see..  You would like to be able to set the "default location text" via the admin control panel?
Hmm, that's not a bad idea, let me look into it a bit.


EDIT: Sorry, I also modified my above post to show you how to do this in a simple way, just incase you missed it.
Title: Re: Adding users location to their posts/topics.
Post by: nokonium on June 26, 2005, 02:33:27 PM
Did you mean index.english.php?
Title: Re: Adding users location to their posts/topics.
Post by: nokonium on June 26, 2005, 02:34:49 PM
Quote from: XBleed on June 26, 2005, 02:32:36 PM
Ohhh, I see..  You would like to be able to set the "default location text" via the admin control panel?
Hmm, that's not a bad idea, let me look into it a bit.


That looks like an even better idea
Title: Re: Adding users location to their posts/topics.
Post by: XBleed on June 26, 2005, 02:37:44 PM
Quote from: nokonium on June 26, 2005, 02:33:27 PM
Did you mean index.english.php?
Yeah, sorry.  Just updated.
Quote from: nokonium on June 26, 2005, 02:34:49 PM
That looks like an even better idea
Yeah, I'm not sure how to go about it yet.  I'll let you know if I figure it out.
Title: Re: Adding users location to their posts/topics.
Post by: nokonium on June 26, 2005, 03:08:39 PM
Thanks
Title: Re: Adding users location to their posts/topics.
Post by: stargazer_1017 on June 26, 2005, 11:27:43 PM
Cool tip! Thank you very much :)

I also wanted to know--where would you put the bold tags to make "Location: " in Bold. I'm not too familiar with coding php, and I don't know where I can put it.

-Shayna
Title: Re: Adding users location to their posts/topics.
Post by: XBleed on June 27, 2005, 09:19:50 AM
Thanks.  :)

If you want to make "Location:" bold, put <strong></strong> tags around $txt[227].  For example:


// Show members location.
if (!empty($message['member']['location']))
echo '
<strong>', $txt[227], ':</strong> ', $message['member']['location'], '<br />
<br />';
Title: Re: Adding users location to their posts/topics.
Post by: stargazer_1017 on June 28, 2005, 02:55:59 AM
Oh okay--thank you so much!

BTW, I noticed that for some reason, it generated an entry for guests in the error log.

8: Use of undefined constant hopelost - assumed 'hopelost'
/home2/crystall/public_html/wits/forum/Themes/Starry_Night/index.template.php (eval?)
144


Is there anyway to stop that?

-Shayna
Title: Re: Adding users location to their posts/topics.
Post by: [Unknown] on June 28, 2005, 02:06:33 PM
Put quotes around the word "hopelost".

-[Unknown]
Title: Re: Adding users location to their posts/topics.
Post by: nokonium on June 28, 2005, 02:31:47 PM
In english.template, index.template or both?
Title: Re: Adding users location to their posts/topics.
Post by: [Unknown] on June 28, 2005, 03:29:48 PM
Well, you'll probably see it like this:

[hopelost]

Change it to:

['hopelost']

-[Unknown]
Title: Re: Adding users location to their posts/topics.
Post by: SaltedWeb on July 29, 2005, 04:11:54 PM
How would one go about changing the word in register and on post to say :

the word City  as opposed to Location.
We deal as a County Group and need ppl putting a city.
Although ppl put the counties name when it says location.

So if we put city they would most likely do it correctly,
then I would ad the show location( city) in postings.

Thanks

Cozmo
Title: Re: Adding users location to their posts/topics.
Post by: [Unknown] on July 29, 2005, 08:34:52 PM
Replace:

', $txt[227], '

With:

City

-[Unknown]
Title: Re: Adding users location to their posts/topics.
Post by: SaltedWeb on July 29, 2005, 09:10:37 PM
Which file would this be in?

And is this with the quotes ?

Thanks

Paul
Title: Re: Adding users location to their posts/topics.
Post by: [Unknown] on July 30, 2005, 01:53:09 AM
With the quotes - in the same file as is mentioned in the first post.

-[Unknown]
Title: Re: Adding users location to their posts/topics.
Post by: SaltedWeb on July 31, 2005, 11:54:04 AM
QuoteOk, just checking wanted to make sure .

Thanks Unknown.


Cozmo
Title: Re: Adding users location to their posts/topics.
Post by: Roach on August 20, 2005, 12:02:09 PM
I hate bumping old threads, but I'm trying to add this to my forum and I've tried to edit the file, but there is not a line that says "Show personal text"...

I tried inserting the code after the lines that would display "Hero Member" etc. but it didn't work.


Suggestions??

Title: Re: Adding users location to their posts/topics.
Post by: [Unknown] on August 26, 2005, 01:13:39 AM
Look for:

if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')

-[Unknown]
Title: Re: Adding users location to their posts/topics.
Post by: -Scott on August 26, 2005, 06:12:25 PM
How do I show the location info in the index template?


-Scott
Title: Re: Adding users location to their posts/topics.
Post by: rojamaia on August 27, 2005, 05:50:22 AM

thanks for this code.

i specially find the "hopelessly lost" funny  :D
Title: Re: Adding users location to their posts/topics.
Post by: [Unknown] on August 28, 2005, 04:47:49 AM
Quote from: -Scott on August 26, 2005, 06:12:25 PM
How do I show the location info in the index template?

I suppose you could use $GLOBALS['user_settings']['location'].

-[Unknown]
Title: Re: Adding users location to their posts/topics.
Post by: rojamaia on August 28, 2005, 03:03:57 PM

i found this error in my error log:

Quote8: Use of undefined constant hopelost - assumed 'hopelost'
File: /discussion/Themes/default/index.template.php (eval?)
Line: 619

what could that "use of undefined constant" mean?  i tried looking for line 619, but index.template.php doesn't have that line
Title: Re: Adding users location to their posts/topics.
Post by: Roach on September 04, 2005, 10:43:22 PM
Quote from: [Unknown] on August 26, 2005, 01:13:39 AM
Look for:

if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')

-[Unknown]

That's not in my theme either. :(  I'm using the ChatBubbles theme.... which doesn't have either of the lines. When I try to add the code it barfs on me for some reason.

RoAcH
Title: Re: Adding users location to their posts/topics.
Post by: ufuk.exe on January 22, 2006, 12:05:49 PM
Hi,
This is great but how can we limit the number of characters users can put on thier profile for location?
I just tested someone can put a whole essay there, and it will show up in the posts.
Title: Re: Adding users location to their posts/topics.
Post by: canuckguy on October 06, 2006, 12:42:18 AM
this should be an option they fix in the next release....my forum no longer shows location in each post either
Title: Re: Adding users location to their posts/topics.
Post by: Aran on October 08, 2006, 06:04:56 PM
// Show their personal text?

I really cant find this, been looking at it line per line but cant see it, anyone can say in what part of the BoardIndex.template.php I can find it?

Edit: Okay my mistake, BoardIndex.template.php was wrong, fixed now.
Title: Re: Adding users location to their posts/topics.
Post by: maritimesbob on January 22, 2007, 09:53:13 PM
I`m not what this mod does, but I was after a hack that added a users location underneath their avatar or post count when they post something. Does this do that?
Title: Re: Adding users location to their posts/topics.
Post by: canuckguy on February 09, 2007, 03:27:30 AM
Aye this does that, or maggies code

http://www.simplemachines.org/community/index.php?topic=140080.msg933825#msg933825
Title: Re: Adding users location to their posts/topics.
Post by: Gorm on May 04, 2007, 04:19:12 PM
Is it posible to code so that location in threads dont show if your a guest?

/Johan
Title: Re: Adding users location to their posts/topics.
Post by: ScewJoel on August 14, 2007, 01:48:47 PM
can anyone help me?
there's no Display.template.php in my theme folder? Theme is: SullenMadness_RC2