PHP Templating API: getSets()
Posted by Mark [Elevated X Support], Last modified by Mark [Elevated X Support] on 19 April 2021 02:29 PM

Description:

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

Sample Usage:

$setobj = $api->getSets();

$setobj = $api->getSets(["id" => 1]);

$setobj = $api->getSets([
"page" => 1,
"id" => 1,
"tourid" => 1,
"numperpage" => 20,
"subsiteid" => 1,
"sort" => "date",
"sort_reverse" => "1",
"newerthan" => "2000-01-01",
"olderthan" => "2010-01-01",
"orderby" => "",
"category_filter" => [4,5,6],
"category_exclude" => "1,2,3",
"model_filter" => [4,5,6],
"model_exclude" => "1,2,3",
"dvd_filter" => [4,5,6],
"dvd_exclude" => "1,2,3",
]);

echo "\nNumber of sets returned: " . $setobj->setcount;
echo "\nNumber of sets total: " . $setobj->settotal;
echo "\nNumber of pages: " . $setobj->numpages;
echo "\nSets:\n";
print_r($setobj->sets);

Returning Attributes:

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

sets:

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

setcount:

The number of sets within the sets attribute.

numpages:

A total number of pages that are available. For instance, if settotal = 400 and the system has a numperpage value of 20, this value will be 20.

settotal:

A total number of sets that are available, regardless of pagination.

Arguments:

page:

This paginates the updates. This way, if you specify "page" => 2, it will show a different list of updates than if you specify "page" => 1.

This is useful if the page you're calling this function on is paginated and you want to show different updates on page 2 of your page than page 1.

By default, the system sets this value to 1 if not specified when passing along to the system.

id:

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

tourid:

If specified, filter sets by those that belong to the specified tour id.

By default, the system detects which tourid (if any) the current area is on and filters by that result.

numperpage:

If specified, determines the maximum number of results to show.

By default, the system looks at the value of "Number of sets per page" in "Index.php Config Options" on the Global Settings page in your admin panel.

subsiteid:

If specified, limit sets belonging to a specified all-access subsite id. If this value is set to 0, show sets from all sites.

By default, the system will detect if the current area belongs to an all-access subsite, and use that value.

Note: If you specify a non-zero value for subsiteid, all-access must be available within this system. Otherwise, an Exception will be triggered.

sort:

Specify sorting order of sets.

Valid values are: title, date, rating, random.

By default, the system will sort by date.

Note: Doing a database sort by random creates a temporary table within mysql, and may result in reduced performance. Only choose this sorting option when absolutely necessary.

sort_reverse:

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

newerthan:

If this value is set, only show sets that are newer than the specified date.

olderthan:

If this value is set, only show sets that are older than the specified date.

category_filter:

If set, only show sets that belong to the specified categories.

By default, the system looks at the value of "Use Categories" in "Index.php Config Options" on the Global Settings page in your admin panel.

Example values:

"category_filter" => ["4,5"]
"category_filter" => [["4,5"]];
"category_filter" => [[4,5]];

Fetch sets that belong to either category ids 4 or 5.

"category_filter" => [[4],[5]];
"category_filter" => "4,5";
"category_filter" => [4,5];

Fetch sets that belong to both category id 4 and category id 5.

"category_filter" => = [[4,5],[6,7]];

Fetch sets that belong either category ids 4 and 5 AND ALSO belong to either categories 6 and 7.

category_exclude:

If set, do not show sets that belong to the specified categories.

By default, the system looks at the value of "Don't use Categories" in "Index.php Config Options" on the Global Settings page in your admin panel.


model_filter:

If set, only show sets that belong to the specified Models.

Example values:

"model_filter" => ["4,5"]
"model_filter" => [["4,5"]];
"model_filter" => [[4,5]];

Fetch sets that belong to either Model ids 4 or 5.

"model_filter" => [[4],[5]];
"model_filter" => "4,5";
"model_filter" => [4,5];

Fetch sets that belong to both Model id 4 and Model id 5.

"model_filter" => = [[4,5],[6,7]];

Fetch sets that belong either Model ids 4 and 5 AND ALSO belong to either Model Ids 6 and 7.

model_exclude:

If set, do not show sets that belong to the specified Models.


dvd_filter:

If set, only show sets that belong to the specified DVDs.

Example values:

"dvd_filter" => ["4,5"]
"dvd_filter" => [["4,5"]];
"dvd_filter" => [[4,5]];

Fetch sets that belong to either DVD ids 4 or 5.

"dvd_filter" => [[4],[5]];
"dvd_filter" => "4,5";
"dvd_filter" => [4,5];

Fetch sets that belong to both DVD id 4 and DVD id 5.

"dvd_filter" => = [[4,5],[6,7]];

Fetch sets that belong either DVD ids 4 and 5 AND ALSO belong to either DVD Ids 6 and 7.

dvd_exclude:

If set, do not show sets that belong to the specified DVDs.

(1 vote(s))
Helpful
Not helpful

Comments (0)