Jump to content

Forum ID in Post object


Turbotailz

Recommended Posts

Posted

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.

Posted

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

Posted

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

Posted

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.

Posted

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 :)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...