perch_events_custom()

Much like the default perch_content_custom() function, Events has perch_events_custom(). This function enables you to get an events listing customized by any of the available parameters.

Requires

Parameters

Type Description
Array Options array, see table below
Boolean Set to true to have the value returned instead of echoed.

Options array

Name Value
category A single category slug or array of category slugs to return content for. To exclude a category, prefix its name with an exclamation point.
template The name of a template to use to display the content.
sort The ID of the field to sort on.
sort-order Either ASC (ascending), DESC (descending) or RAND (random).
sort-type Either alpha or numeric. Default is alpha.
count The number of items to display.
start The item number to start displaying from.
filter The ID of a field to filter the results by.
match Used with filter, see the below table for values
value Used with filter and match. The value to match. For between and in, takes a comma delimited string. For regex takes PCRE regular expression.
category Filter by one or more categories. See Category filtering
category-match Either any or all. See Category filtering
skip-template True or false. Bypass template processing and return the content in an associative array.
return-html True or false. For use with skip-template. Adds the HTML onto the end of the returned array with key html.
split-items True or false. Return an array of individually templated items.
raw True or false. Returns unprocessed content, for use alongside skip-template.

Possible values for match

Value Aliases Description
eq is, exact equal to
neq not, !eq not equal to
gt greater than
gte greater than or equal to
lt less than
lte less than or equal to
contains the value exists within the content (a simple search)
!contains opposite of contains: the value does not exist within the content
regex regexp using a PCRE regular expression
between match between two values
!between opposite of between
eqbetween match between two values inclusively
!eqbetween opposite of eqbetween
in within match within a comma delimited content list (like a list of tags)
!in !within opposite of in

Usage examples

The following example would select all dates equal to or between the 3rd August 2010 and the 14th August 2010, in the categories of picnics or concerts. We also pass in a template.

<?php
perch_events_custom(array(
    'filter'   => 'eventDateTime',
    'match'    => 'eqbetween',
    'value'    => '2010-08-03, 2010-08-14',
    'category' => array('picnics', 'concerts'),
    'template' => 'events/listing/event-day.html'
));
?>

Return the array to a variable for further processing.

<?php
$events = perch_events_custom(array(
    'filter'   => 'eventDateTime',
    'match'    => 'eqbetween',
    'value'    => '2010-08-03, 2010-08-14',
    'category' => array('picnics', 'concerts'),
    'template' => 'events/listing/event-day.html'
),true);
?>