Turbotailz Posted May 9, 2018 Posted May 9, 2018 I'd like to be able to differentiate where a post is submitted by checking the forum it was posted in. I feel like adding Forum ID to the Post object would be a good addition. May as well add Topic ID to it as well.
Daniel F Posted May 9, 2018 Posted May 9, 2018 You can already access the topic by using $comment->item() and the Item class has a method called container() which would return you then the forum object
Turbotailz Posted May 9, 2018 Author Posted May 9, 2018 Sorry, I should have mentioned this is for the REST API.
Daniel F Posted May 9, 2018 Posted May 9, 2018 The post response returns the topic id , so you could use a second REST request to the topic endpoint which will return the topic and also forum details
Martin A. Posted May 9, 2018 Posted May 9, 2018 In the post return, you'll get the item ID. You can do an additional call to "/forums/topics/{id}", where you'll get info about the forum too. Or if this is for your own site, you can create a hook that overloads \IPS\Content\Comment::apiOutput(), and add the forum ID to what it returns. public function apiOutput( \IPS\Member $authorizedMember = NULL ) { $parentReturn = parent::apiOutput( $authorizedMember ); $parentReturn['forum'] = $this->item()->container()->apiOutput( $authorizedMember ); return $parentReturn; } Untested.
Turbotailz Posted May 9, 2018 Author Posted May 9, 2018 Oh right, I didn't realise the item_id was the topic ID. This should be fine, though I don't really want to be making multiple API requests but I'll take what I can get! Thanks :)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.