Advertisement:

Author Topic: Adding users location to their posts/topics.  (Read 31532 times)

Offline XBleed

  • Semi-Newbie
  • *
  • Posts: 10
Adding users location to their posts/topics.
« 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:
Code: [Select]
// Show their personal text?
ABOVE that, add:

Code: [Select]
                  // 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.
« Last Edit: June 27, 2005, 09:20:38 AM by XBleed »

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Adding users location to their posts/topics.
« Reply #1 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

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

« Last Edit: June 26, 2005, 12:41:47 PM by nokonium »



Offline XBleed

  • Semi-Newbie
  • *
  • Posts: 10
Re: Adding users location to their posts/topics.
« Reply #2 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:

Code: [Select]
$txt[227] = 'Location';
BELOW that add:

Code: [Select]
$txt[hopelost] = 'Hoplessly lost';
Now open Themes/Your_Theme_Folder/Display.template.php and find:

Code: [Select]
// Show their personal text?

ABOVE that, add:

Code: [Select]
// 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 />';
« Last Edit: June 26, 2005, 02:36:49 PM by XBleed »

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Adding users location to their posts/topics.
« Reply #3 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,




P.S.
PNL=Post Nutritive Liquid



Offline XBleed

  • Semi-Newbie
  • *
  • Posts: 10
Re: Adding users location to their posts/topics.
« Reply #4 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.

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Adding users location to their posts/topics.
« Reply #5 on: June 26, 2005, 02:33:27 PM »
Did you mean index.english.php?



Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Adding users location to their posts/topics.
« Reply #6 on: June 26, 2005, 02:34:49 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



Offline XBleed

  • Semi-Newbie
  • *
  • Posts: 10
Re: Adding users location to their posts/topics.
« Reply #7 on: June 26, 2005, 02:37:44 PM »
Did you mean index.english.php?
Yeah, sorry.  Just updated.
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.

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Adding users location to their posts/topics.
« Reply #8 on: June 26, 2005, 03:08:39 PM »
Thanks



Offline stargazer_1017

  • Jr. Member
  • **
  • Posts: 123
  • Gender: Female
Re: Adding users location to their posts/topics.
« Reply #9 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

Offline XBleed

  • Semi-Newbie
  • *
  • Posts: 10
Re: Adding users location to their posts/topics.
« Reply #10 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:

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

Offline stargazer_1017

  • Jr. Member
  • **
  • Posts: 123
  • Gender: Female
Re: Adding users location to their posts/topics.
« Reply #11 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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Adding users location to their posts/topics.
« Reply #12 on: June 28, 2005, 02:06:33 PM »
Put quotes around the word "hopelost".

-[Unknown]

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Adding users location to their posts/topics.
« Reply #13 on: June 28, 2005, 02:31:47 PM »
In english.template, index.template or both?



Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Adding users location to their posts/topics.
« Reply #14 on: June 28, 2005, 03:29:48 PM »
Well, you'll probably see it like this:

[hopelost]

Change it to:

['hopelost']

-[Unknown]

Offline SaltedWeb

  • Full Member
  • ***
  • Posts: 618
  • Why do we use the Internet...Hayes 1200 Thats Why
Re: Adding users location to their posts/topics.
« Reply #15 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
Multi-Linking, like a Boss.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Adding users location to their posts/topics.
« Reply #16 on: July 29, 2005, 08:34:52 PM »
Replace:

', $txt[227], '

With:

City

-[Unknown]

Offline SaltedWeb

  • Full Member
  • ***
  • Posts: 618
  • Why do we use the Internet...Hayes 1200 Thats Why
Re: Adding users location to their posts/topics.
« Reply #17 on: July 29, 2005, 09:10:37 PM »
Which file would this be in?

And is this with the quotes ?

Thanks

Paul
Multi-Linking, like a Boss.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Adding users location to their posts/topics.
« Reply #18 on: July 30, 2005, 01:53:09 AM »
With the quotes - in the same file as is mentioned in the first post.

-[Unknown]

Offline SaltedWeb

  • Full Member
  • ***
  • Posts: 618
  • Why do we use the Internet...Hayes 1200 Thats Why
Re: Adding users location to their posts/topics.
« Reply #19 on: July 31, 2005, 11:54:04 AM »
Quote
Ok, just checking wanted to make sure .

Thanks Unknown.


Cozmo
Multi-Linking, like a Boss.