PHP Templating API: getModels()
Posted by Mark [Elevated X Support], Last modified by Mark [Elevated X Support] on 10 March 2021 04:25 PM
The getModels() function gets a list of models that are present in the system. Based on the arguments that are passed to it will determine which and how many models are returned.
$modelobj = $api->getModels();
This function call will return a StdObject object with the following attributes:
This is a multi-dimensional array that returns any models that match search criteria.
The number of sets within the models attribute.
A total number of pages that are available. For instance, if modeltotal = 400 and the system has a numperpage value of 20, this value will be 20.
A total number of models that are available, regardless of pagination.
This paginates the model list. This way, if you specify "page" => 2, it will show a different list of models than if you specify "page" => 1.
This filters the results by model id. If set, this will only return a set of the specified model id, if it is available for release and is present on the current site.
If specified, determines the maximum number of results to show.
If specified, only return models that belong to the specified gender.
If specified, only show models that begin with the specified letter.
Specify sorting order of sets.
If this is set to 1, reverse the sorting order as specified within "sort"
If specified, limit models belonging to a specified all-access subsite id. If this value is set to 0, show sets from all sites.
If specified, limit models based on extra field search criteria.
In order to do a search with this, you'll need to pass an associative array, where:
- The key specifies the Extra Field Id of the item you're searching. You can find this ID in /cms_admin/plugins/extrafields/extrafields.php
- The value of the array is an exact match of the string that you're searching.