News:

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

Main Menu

Adding users location to their posts/topics.

Started by XBleed, May 23, 2005, 01:39:50 PM

Previous topic - Next topic

XBleed

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.

nokonium

#1
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 />';





XBleed

#2
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 />';

nokonium

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,




P.S.
PNL=Post Nutritive Liquid



XBleed

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.

nokonium




nokonium

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



XBleed

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.

nokonium




stargazer_1017

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

XBleed

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 />';

stargazer_1017

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

[Unknown]

Put quotes around the word "hopelost".

-[Unknown]

nokonium

In english.template, index.template or both?



[Unknown]

Well, you'll probably see it like this:

[hopelost]

Change it to:

['hopelost']

-[Unknown]

SaltedWeb

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
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

[Unknown]

Replace:

', $txt[227], '

With:

City

-[Unknown]

SaltedWeb

Which file would this be in?

And is this with the quotes ?

Thanks

Paul
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

[Unknown]

With the quotes - in the same file as is mentioned in the first post.

-[Unknown]

SaltedWeb

QuoteOk, just checking wanted to make sure .

Thanks Unknown.


Cozmo
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

Advertisement: