PDA

View Full Version : [RELEASE] Location, Interests, etc. in post!


07-14-2000, 08:59 PM
Well, it's so simple, it's not even a hack in my book :)

I'm only giving example code for Location and Interests, but the rest are similar.

1.1.4 compliant


Find:
-----------
$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as postid,post.pagetext as pagetext,
post.allowsmilie as allowsmilie,post.signature AS showsignature,post.title as title,
post.ipaddress as ipaddress,post.iconid as iconid,post.username as fakename,
post.userid as userid,
user.userid as userid,user.email as email,user.username as username,
user.usertitle as usertitle,user.signature as signature,user.showemail as showemail,
user.homepage as homepage,user.icq as icq,user.aim as aim,user.yahoo as yahoo,
user.joindate as joindate,user.posts as posts
FROM post
LEFT JOIN user ON (user.userid = post.userid)
WHERE post.threadid=$threadid AND visible=1
ORDER BY dateline $postorder
LIMIT $limitlower,$perpage");
-----------

Add to the end of the SELECT portion:
-----------
,user.biography as biography
-----------

Find:
-----------
$userinfo=$post;
-----------

Under it, add:
------------
$bio = split("\n", trim($userinfo[biography]));
$location = "";
$interests = "";
while(list($key,$val)=each($bio)) {
if (strlen(strpos($val, 'Location:'))) {
$location = eregi_replace("^Location:([^\\[]*)", "\\1", "$val");
} elseif (strlen(strpos($val, 'Interests:'))) {
$interests = eregi_replace("^Interests:([^\\[]*)", "\\1", "$val");
}
}
if ($location) { $location = "Location: $location"; }
if ($interests) { $interests = "Interests: $interests"; }
------------

Then reference $location and/or $interests in the postbit template.


Now, just reference $location and $interests in the postbit template.

Enjoy!

[Edited by Ed Sullivan on 12-04-2000 at 02:08 PM]

07-14-2000, 09:04 PM
Thank you, thank you, thank you!!!!!!

This works perfectly! It was so important for me to have the interest & location fields on the posts, and now they are there!

07-15-2000, 10:10 AM
thanks great work.. i added it to my forum and it works great :D

07-15-2000, 10:20 AM
i have a problem in this thread is an example

http://www.animeboards.net/forums/showthread.php?threadid=565

my location display is repeated as the thread goes down ?

07-15-2000, 10:27 AM
it seems that if a member does not have a location field in their profile the previous posts' user's location is added ?

07-15-2000, 01:13 PM
ahh - oops. Simple fix.

change:
if ($location) { $location = "Location: $location"; }
if ($interests) { $interests = "Interests: $interests"; }

to

if ($location) { $location = "Location: $location"; } else { $location = ""; }
if ($interests) { $interests = "Interests: $interests"; } else { $interests = ""; }

07-15-2000, 01:34 PM
thanks ed, but it didn't work ?

in this thread
http://www.animeboards.net/forums/showthread.php?threadid=539

user called Hiyoku

keeps on displaying the previous poster's location with an added 'Location:' in it

i.e.


Hiyoku
Member

Registered: Jul 2000
Location: Location: USA
Posts: 77

-------

Hiyoku
Member

Registered: Jul 2000
Location: Location: Brisbane, Australia
Posts: 77



from this thread
http://www.animeboards.net/forums/showthread.php?threadid=539 ?

07-15-2000, 01:40 PM
oh yeah the exact same thing occurs with the interest info

where a user does not have an interest in their profile, they take the previous poster's interests

i.e. in the last post in

http://www.animeboards.net/forums/showthread.php?threadid=571


sorry not last post but further up

[Edited by eva2000 on 07-15-2000 at 10:50 AM]

07-15-2000, 06:55 PM
Doh! Stupid me. Fixed the glitches in the original code.

Just add this code above the while(... line:
$location = "";
$interests = "";

07-15-2000, 07:03 PM
but it's already there ? :confused:

whoops... sorry i didn't realise you edited and corrected the original post



[Edited by eva2000 on 07-15-2000 at 04:08 PM]

07-15-2000, 07:09 PM
[post now null and void. But I don't feel like deleting it so nah!]

[Edited by Ed Sullivan on 07-15-2000 at 04:16 PM]

07-15-2000, 07:20 PM
well thanks Ed... it works perfectly now https://vborg.vbsupport.ru/

07-15-2000, 07:35 PM
Yay!

07-15-2000, 11:04 PM
Remove this part


if ($location) { $location = "Location: $location"; }

if ($interests) { $interests = "Interests: $interests"; }


and you can put the Location: part in the template

07-16-2000, 12:43 AM
No John, that's intentional.

Otherwise, user's without a $location or $interests, will show up as:
Location:
Interests:As it is now, nothing will show up, making a cleaner display.

07-16-2000, 01:25 AM
Even cleaner:

Old:
if ($location) { $location = "Location: $location"; }

New:
if ($location) { $location = "Location: $location<br>"; }

That way, if there's no location, there's no linefeed.

[Ed's Edit: Sorry, you missed a "$", fixed now]

[Edited by Ed Sullivan on 07-15-2000 at 10:47 PM]

07-16-2000, 02:05 AM
Ah, that makes sense. :)

07-16-2000, 09:17 AM
Originally posted by Dave Baker
Even cleaner:

Old:
if ($location) { $location = "Location: $location"; }

New:
if ($location) { $location = "Location: $location<br>"; }

That way, if there's no location, there's no linefeed.

[Ed's Edit: Sorry, you missed a "$", fixed now]

[Edited by Ed Sullivan on 07-15-2000 at 10:47 PM] hehe my members love the new addition by Ed :D what does it mean 'no linefeed' ?

07-16-2000, 08:18 PM
Ed:

Don't you want to include:

if ($userinfo[receivepm]=="1") {
$pmlink = "<a href=\"private.php?action=newmessage&toid=$userinfo[userid]\"><img src=\"images/pm.gif\" border=0></a>&nbsp;";
} else {
$pmlink = "";
}

in this if you are using Private Messages 1.2?

Parker

07-17-2000, 12:59 AM
By "no linefeed" I mean no blank line.

07-17-2000, 02:02 AM
Parker - don't replace that part, I didn't tell you to :)

Only replace what I said to replace there with what I told you to replace it with - no more, no less. If you follow the directions, you will still have the other PM related stuff there.

07-17-2000, 04:29 PM
just thought i'd add

the location/interest hack works on my upgraded 1.1.3 beta 3 forum too :D

thanks Ed :D

07-20-2000, 09:15 AM
Ed, can you add a third field into there for me? Let's say I want to add "occupation" to it, how would add that in addition to the other ones?

07-20-2000, 02:32 PM
if ($userid!=0) {
//PM Hack
//Original: $userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemai l,homepage,icq,aim,yahoo,joindate,posts FROM user WHERE userid=$userid");
//New:
$userinfo=$DB_site->query_first("SELECT userid,email,biography,username,usertitle,signatur e,showemail,homepage,icq,aim,yahoo,joindate,posts, receivepm FROM user WHERE userid=$userid");
$bio = split("\n", trim($userinfo[biography]));
$location = "";
$interests = "";
$occupation = "";
while(list($key,$val)=each($bio)) {
if (strlen(strpos($val, 'Location:'))) {
$location = eregi_replace("^Location:([^\\[]*)", "\\1", "$val");
} elseif (strlen(strpos($val, 'Interests:'))) {
$interests = eregi_replace("^Interests:([^\\[]*)", "\\1", "$val");
} elseif (strlen(strpos($val, 'Occupation:'))) {
$occupation = eregi_replace("^Occupation:([^\\[]*)", "\\1", "$val");
}
}
if ($location) { $location = "Location: $location"; }
if ($interests) { $interests = "Interests: $interests"; }
if ($occupation) { $occupation = "Occupation: $occupation"; }

[Edited by Ed Sullivan on 07-20-2000 at 11:34 AM]

07-31-2000, 03:22 PM
okay... how does one reapply the location/interest hack in light of installing rangersfan's avatar hack at http://vbulletin.com/forum/showthread.php?threadid=2127 ?

07-31-2000, 03:55 PM
Don't replace the $userinfo=$DB_site-> line, just add biography to where I told you to add if before. Then just add the rest of the code the same way.

07-31-2000, 04:28 PM
Just add 'iconpath' along side 'biography.

07-31-2000, 04:44 PM
do you mean add to showthread.php ? where ? in the below code ?

if ($userid!=0) {
$userinfo=$DB_site->query_first("SELECT userid,email,username,biography,usertitle,signatur e,showemail,homepage,icq,aim,yahoo,joindate,posts FROM user WHERE userid=$userid");
$bio = split("\n", trim($userinfo[biography]));
$location = "";
$interests = "";
while(list($key,$val)=each($bio)) {
if (strlen(strpos($val, 'Location:'))) {
$location = eregi_replace("^Location:([^\\[]*)", "\\1", "$val");
} elseif (strlen(strpos($val, 'Interests:'))) {
$interests = eregi_replace("^Interests:([^\\[]*)", "\\1", "$val");
}
}
if ($location) { $location = "Location: $location"; }
if ($interests) { $interests = "Interests: $interests"; }

07-31-2000, 04:56 PM
I don't really understand as you appear to have it working on your forum.

If you are trying to get the location back to working. Just add 'iconpath' in the following like this:

$userinfo=$DB_site->query_first("SELECT userid,email,username,biography,usertitle,signatur e,showemail,homepage,icq,aim,y ahoo,joindate,posts,iconpath

07-31-2000, 05:47 PM
yeah i want to bring back location display...the thing is i have this already in showthreads

This is what i have:
[quote]if ($userid!=0) {
$userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemai l,homepage,icq,aim,yahoo,joind ate,posts,iconpath FROM user WHERE userid=$userid");
$bio = split("\n", trim($userinfo[biography]));
$location = "";
$interests = "";
while(list($key,$val)=each($bio)) {
if (strlen(strpos($val, 'Location:'))) {
$location = eregi_replace("^Location:([^\\[]*)", "\\1", "$val");
} elseif (strlen(strpos($val, 'Interests:'))) {
$interests = eregi_replace("^Interests:([^\\[]*)", "\\1", "$val");
}
}
if ($location) { $location = "Location: $location"; }
if ($interests) { $interests = "Interests: $interests"; }[quote]

07-31-2000, 06:08 PM
You need to stick "biography" back in the field list. Add ",biography" after "iconpath"

07-31-2000, 06:49 PM
yep, that worked adding ,biography after iconpath, line :D

yipee :D

thanks guys :)

11-06-2000, 10:28 AM
This is a really nice hack, but it looks like the code changed in 1.14. I can't find anything that resembles this in showthread.php:

$userinfo=$DB_site->query_first("SELECT userid,email,username,usertitle,signature,showemai l,homepage,icq,aim,yahoo,joindate,posts FROM user WHERE userid=$userid");


Any plans on updating this, or is it better to wait until version 2.0?

Thanks,
TigerLily:)

11-06-2000, 10:54 AM
Yep. Line has changed to:
$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as etc...

11-06-2000, 11:29 AM
Tack this:
,user.biography as biography
to the end of the SELECT section.

11-07-2000, 06:53 PM
Thanks, Ed, but I still can't get it to show up. I'm sure I'm doing something wrong! Since the code is different, where do you put this part?

$bio = split("\n", trim($userinfo[biography]));
$location = "";
$interests = "";
while(list($key,$val)=each($bio)) {
if (strlen(strpos($val, 'Location:'))) {
$location = eregi_replace("^Location:([^\\[]*)", "\\1", "$val");
} elseif (strlen(strpos($val, 'Interests:'))) {
$interests = eregi_replace("^Interests:([^\\[]*)", "\\1", "$val");
}
}
if ($location) { $location = "Location: $location"; }
if ($interests) { $interests = "Interests: $interests"; }


I've tried putting the code right beneath the changed line and farther down. I've called the $location in the templates, but nothing shows up. Not sure what I'm doing wrong!
TigerLily:)

11-07-2000, 08:04 PM
Put that under
$userinfo = $post;

11-15-2000, 03:14 AM
Thanks so much, Ed! Works like a charm now!
TigerLily:)

12-04-2000, 05:11 PM
<bump>

Instructions for 1.1.4 in original post now.

01-11-2001, 03:45 AM
Just thaught I would bring this back to the top and say it works fine with 1.1.5
just installed it on my test board
http://www.clubbers.ws/forums/showthread.php?threadid=1

02-05-2001, 05:39 AM
Hi, I'm really whit all that.

Where i put the code. I really dont know what to do whit that code in the first post of that tread.:(

I dont find the line whit the SELECT thing in any templates. If i search at the right place. Anyone can help me a bit Pls.

02-05-2001, 07:29 AM
you put it in the showthread.php file

02-05-2001, 03:05 PM
Thx a lot Goldfinger, i will try it this morning.

02-05-2001, 06:28 PM
not a problem thats what the forums are for.

02-06-2001, 11:43 AM
Thx you very much guy :D