Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Topics started and topics posted to buttons
Avatar
js
Member
Free Members
Offline
Nov 5, 2012 - 2:35 pm

I am wondering if its possible to display the 'topic started' and 'topics posted to' buttons for members on a non sp profile page? Would like them to function the same way they normally do and lead back to the forum search when clicked. Any advice will be appreciated.  

Avatar
Yellow Swordfish
Glinton, England
SP Master
Offline
Nov 5, 2012 - 2:56 pm

Yes that is entirely possible. With one condition.

If you run the searches from your forum and copy the url that is in the address bar when the page loads you can use those urls anywhere you like.

The condition, however, is that the 'value' query variable has to be the ID of the current user or the user you wish to search for. So 'topics started' would look like this:

http://*your-domain*/*your-for.....038;type=5

but that will display the topics started by user ID of 3. SO all is well as long you know the ID of the user... and can then construct the URL accordingly.

andy-signature.png
YELLOW
SWORDFISH
Avatar
js
Member
Free Members
Offline
Nov 5, 2012 - 6:55 pm

I did check out the url after running a search and saw the user ID included. Also took a look at the function sp_ProfileShowSearchPosts in the sp-profile-view-functions.php being used by sp for the searches. However, the code to accomplish this is beyond me. If it's not too much trouble could you show me an example of how the 'topics started' could be done?  

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
Nov 5, 2012 - 8:08 pm

kind of hard to be exact or specific not knowing where you would put it...

but something like this where you want it:

<?php
global $current_user;
echo '<a href="http://*your-domain*/*your-forum-name*/?search=1&new=1&forum=all&value='.$current_user->ID.'&type=5">Search</a>';
?>

of course, this assumes there is a user... you could add a check for a user

if (!empty($current_user->ID)) ...

before outputting the link to search...  and you need to replace *your-domain* and *your-forum-name* with your site specifics...

Avatar
js
Member
Free Members
Offline
Nov 15, 2012 - 5:01 pm

Thanks that was exactly what I needed to figure out what I was trying to do :) Profile pages are bp and the code I ended up using (minus the css) to get the buttons in the member-header of the pages was-

global $bp;
echo '<a href="*your-domain*/*your-forum*/?search=1&new=1&forum=all&value='.$bp->displayed_user->id.'&type=5">Topics Started</a>'; ?>

Avatar
Yellow Swordfish
Glinton, England
SP Master
Offline
Nov 16, 2012 - 3:55 am

Thanks for the update and glad you got it working.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626