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
Getting a reference to the post_ID
Avatar
Chris Smith
Member
Free Members
sp_UserOfflineSmall Offline
May 14, 2012 - 5:59 pm

I am now using sph_display_post_content_filter to add some content as a footer. The content is stored in the database sfposts in a separate column. In order to retrieve the data from the database I need to know the post_ID for the query, and was wondering how I could get that reference. Thanks.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 14, 2012 - 10:05 pm

not sure what you are really doing and what you want it for...  are you in the topic view loop here (ie the outputting of a post)??

depending on the various page view type (ie group, forum, topic, etc), we have a defined some global objects that are available for you to use for looking at or getting data... can save on a db query...

I would suggest going to forum - toolbox - data inspector and turning on some of the 'debug' display of the available data so you can see what is already available...

I suspect what you want is $spThisPost->post_id but not sure what you are going to do with it...  the 'real' data you want may already be available...

Avatar
Chris Smith
Member
Free Members
sp_UserOfflineSmall Offline
May 15, 2012 - 11:01 am

Thanks for your response the data inspector was really helpful. However, I just realized how vague my initial post was.

What I am trying to do is write a plugin that lets users thank another user and then display who has thanked the user. The plugin might eventually use the number of thanks, along with other factors (# of posts, activity, registration date) to give a user ranking. Right now in the sfmembers table I will have two extra columns one with the post ID's of what the user has thanked and another for the post ID's of the user that have been thanked by other users. I will also have an extra column in the sfposts table that will have the member ID's of those that have thanked that post. I have been able to get all the install and uninstall of the plugin and its database edits to work successfully.

I am now having trouble trying to figure out how I should display the users that have thanked the post during the post loop. I probably should not be using the sph_display_post_content_filter to do this, but didn't know what hook I could use that would let me get the post data object that is shown in the output of the data inspector for spThisTopic. Any suggestions would be appreciated.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 15, 2012 - 12:10 pm

The best way to do this is actually with a template function. These are the functions used in the theme templates to display data.

Take a look at the files in /simple-press/forum/content and you will find all of the functions used for the forum display in their various views.

These should help you with the structure we are using and you sound savvy enough to probably work that out.

With Sp plugins we would normally define a 'template-tags' folder to keep these functions in. A plugin like Subscriptions - for example - would be worth looking at so you can see the structure.

This kind of feature - or features like it - have been asked for by many users. I don't know if you would be willing to share when you have it all done but we would certainly be interested and willing to help you with it as far as possible.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Chris Smith
Member
Free Members
sp_UserOfflineSmall Offline
May 15, 2012 - 4:22 pm

Thanks, that sounds like it will be a much better way of approaching the problem. I have started working on it and so far it is working decently. I will keep you updated on the progress, and would be willing to share once it is done.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 15, 2012 - 10:11 pm

please do. and let us know if you have any questions or issues.

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: 616
Members: 17348
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10118
Posts: 79603