Dan

How do i load the post comment object via the class namespace?

Recommended Posts

I have created a rule that does an action when a topic is hidden, but unfortunately I can;t seem to load the post object to get the post content because a topic doesn't contain that information.

To be perfectly honest I don't even know where to find documentation on all the class namespaces, so I have kind of been guessing most the way.

What am i doing wrong here?

$post = \IPS\Content\Item::load( $content->topic_firstpost );

Is what I'm doing not even possible?

Edited by Dan

Share this post


Link to post
Share on other sites

Another way would be:
 

$post = $content->comments(1,0);

The IPS\forums\Topic object model has the following core method on it:

/**
 * Get comments
 *
 * @param	int|NULL			$limit					The number to get (NULL to use static::getCommentsPerPage())
 * @param	int|NULL			$offset					The number to start at (NULL to examine \IPS\Request::i()->page)
 * @param	string				$order					The column to order by
 * @param	string				$orderDirection			"asc" or "desc"
 * @param	\IPS\Member|NULL	$member					If specified, will only get comments by that member
 * @param	bool|NULL			$includeHiddenComments	Include hidden comments or not? NULL to base of currently logged in member's permissions
 * @param	\IPS\DateTime|NULL	$cutoff					If an \IPS\DateTime object is provided, only comments posted AFTER that date will be included
 * @param	mixed				$extraWhereClause	Additional where clause(s) (see \IPS\Db::build for details)
 * @param	bool|NULL			$bypassCache			Used in cases where comments may have already been loaded i.e. splitting comments on an item.
 * @param	bool				$includeDeleted			Include Deleted Content
 * @param	bool|NULL			$canViewWarn			TRUE to include Warning information, NULL to determine automatically based on moderator permissions.
 * @return	array|NULL|\IPS\Content\Comment	If $limit is 1, will return \IPS\Content\Comment or NULL for no results. For any other number, will return an array.
 */
public function comments( $limit=NULL, $offset=NULL, $order='date', $orderDirection='asc', $member=NULL, $includeHiddenComments=NULL, $cutoff=NULL, $extraWhereClause=NULL, $bypassCache=FALSE, $includeDeleted=FALSE, $canViewWarn=NULL )

 

  • Like 1

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.