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
Constructing topic url
Avatar
JohnnyNT
Member
Free Members
Offline
Mar 8, 2012 - 6:36 am

I was trying to find some function that will construct topic url if i pass topic id and forum id to that function. Is there something like that?

Avatar
Yellow Swordfish
Glinton, England
SP Master
Offline
Mar 8, 2012 - 6:57 am

There was in V4 but not in V5 as we no longer use that internally.

I don't know where you are getting your data from but out main urkl builder nbowe uses the slugs instead of the id. Th call is:

sp_build_url($forumslug, $topicslug, $pageid);

which takes the two slugs and a page ID. If you just want the first page just pass a 1.

If you donlt have the slugs available come back and we can discuss other options but let me kbnow where you wnat to make this call from.

andy-signature.png
YELLOW
SWORDFISH
Avatar
JohnnyNT
Member
Free Members
Offline
Mar 8, 2012 - 10:09 am

^ Great, this works, tnx. Yes, i have slug available, 'couse i query database (wp_sftopics) for some other needs. Btw, i am making this call from template file spHead.php - making some sort of latest-topic thing that will show some "teaser" from VIP part of forum (but for all memebers, no mather usergroup). This url-thing is needed so that users from VIP usergroup can click on that "teaser" and go to VIP part of forum (and specified thread), and all others to be redirected to some other page.

 

I almost finished it, but i have new question...  how can i get current user id in this head template file (spHead.php)? 

Avatar
Yellow Swordfish
Glinton, England
SP Master
Offline
Mar 8, 2012 - 10:22 am

Extensive details on the current user can be found in the global $spThisUser - for their ID use:

$spThisUser->ID

if you need any other information on the user then use the forum admin > toolbox > data inspector - turn on the $spThisUser item and load any forum page - you will see all the elements of the data object that are available for use.

Hope it works out...

andy-signature.png
YELLOW
SWORDFISH
Avatar
JohnnyNT
Member
Free Members
Offline
Mar 8, 2012 - 10:44 am

Cool tool, i didnt know it exists 😀 Ok, i made mistake in my previous post, i already knew how i can get current user id, what i really need is current user membership id (or name of usergroup, whatever). Yes, i tried to get it with data inspector but i get only empty array (or i made mistake somewhere).

EDIT:

I found it (i was little confused, it is array inside of array), here it is: 

$spThisUser->memberships[0]['usergroup_id'] 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
Mar 8, 2012 - 9:26 pm

yup. that's it...

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: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17348
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10120
Posts: 79607