PHP Templating API: getComments() Print

  • 0

Description:

The getComments() function gets a list of comments that are present in the system. Based on the arguments that are passed to it will determine which and how many comments are returned.

Sample Usage:

$commentobj = $api->getComments("contenttype" => "set");

$commentobj = $api->getComments(["itemid" => 1, "contenttype" => "set]);

$commentobj = $api->getComments([
"contenttype" => "set",
"sort" => "id",
"sort_reverse" => 1,
"countonly" => 0,
]);

echo "\nNumber of comments returned: " . $commentobj->commentcount;
echo "\nComments:\n";
print_r($commentobj->models);

Returning Attributes:

This function call will return a StdObject object with the following attributes:

comments:

This is a multi-dimensional array that returns any comments that match search criteria.

commentcount:

The number of comments returned.

Arguments:

contenttype:

This specifies the type of comment that is being fetched. This field is required.

Valid values for this field are: set, news, model, dvd, custompages, store

id:

If set, this will only return a single comment matching that specific comment id in the system. This may be useful if you wish to highlight a specific comment left in the system.

itemid:

This filters the results by the itemid. If set, this will only return a set of the specified item id, if it is available for release and is present on the current site.

This is commonly used with the contenttype argument:

$commentobj = $api->getComments(["itemid" => 1, "contenttype" => "set]);

In this case, you will get comments for Set Id #1.

sort:

Specify sorting order of comments.

Valid values are: id

By default, the system will sort by id.

Note: Future sorting options will be available in a future API release.

sort_reverse:

If this is set to 1, reverse the sorting order as specified within "sort"

countonly:

If specified, only return the number of areas that fit the search criteria.



Was this answer helpful?

« Back