MediaSearch
The Media Search EVML object allows Theme developers to build functionality for Media Library directories.
<?ev
// Create a new media search object
var search = new MediaSearch();
// Get a search string from query parameters
var phrase = request.param('q', '');
search.find(phrase);
// Search within the Images Media Library
search.directory('~/content/images');
// You can paginate the results
search.limit(25);
search.requestPagination();
// Iterate across results
for (var mediapath of search) {
dump(mediapath);
}
?>
<!-- Draw pagination -->
<ev:pagination object="search" />
Methods |
---|
directory(String:path)
MediaSearch
Returns the original MediaSearch object allowing for method chaining. |
find(String:phrase)
MediaSearch
Sets a search phrase to match against file names. Returns the original MediaSearch object. |
hasNextPage()
Boolean
Returns |
hasPreviousPage()
Boolean
Returns |
hasResults()
Boolean
Returns |
hasSortString(String:value)
Boolean
Returns |
isFirstPage()
Boolean
Returns |
isLastPage()
Boolean
Returns |
length()
Number
The number of items within the current result set. This will be less than or equal to the page size. |
limit(Number:length)
MediaSearch
Sets the result set limit to return in the search. |
nextPage()
Number
| null
Returns the Number of the next page in the results sequence. Returns |
nextPageUrl()
Url
| null
Returns the Url of the next page in the results sequence. Returns |
offset(Number:displacement)
MediaSearch
Sets the index from which to search from. Offset is zero indexed. |
orderBy(String:order)
MediaSearch
Not implemented for this search object. All results are ordered by title only. |
page([Number:num])
MediaSearch
Gets or sets the current page number of the search results. |
perPage([Number:limit])
MediaSearch
Gets or sets the result set size per page. |
phrase()
String
The key phrase to find in the search. |
previousPage()
Number
| null
Returns the Number of the previous page in the results sequence. Returns |
previousPageUrl()
Url
| null
Returns the Url of the previous page in the results sequence. Returns |
requestPagination()
Automate
|
results()
MediaFilePath[]
An Array of MediaFilePath objects. |
sort(String:sortstring)
Alias of |
total()
Number
The total number of results available for the search. |
totalPages()
Number
The total number of pages available for the search. |