Hype5 Theater 0.6.17 · Pre-release
Queries and URL parameters
On this page
- Rendering a collection from PHP
- URL parameters
- Collection routes
- Query services
- Data\CollectionRequest::normalize(array $attributes = [], array $request = []): array
- Data\ProductionQuery::find(array $args): array
- Data\ProductionQuery::next(array $ids): array
- Data\PersonQuery::find(array $args): array
- Data\ScheduleQuery::find(array $args = []): array and count(array $args = []): int
- Cards and rows for output
- Example: the next dates of one production
Collections (productions, people, schedule) read their filters from URL parameters and from shortcode attributes, and are built on a small set of query services. This page documents the URL contract, the collection routes and the PHP query services. For the visibility guarantees and stability classification of each service, see Stage presentation services.
Rendering a collection from PHP
echo \Hype5\Theater\Frontend\Collections::render('productions', ['context' => 'upcoming', 'filters' => '0']);
Collections::render(string $type, array $attributes = []): string accepts productions, people or schedule and the attributes of the matching shortcode. It is the same code path as the shortcodes and blocks.
URL parameters
| Parameter | Collections | Meaning |
|---|---|---|
hype5_context |
productions | current, upcoming, archive |
hype5_search |
productions, people | WordPress search text |
hype5_genre, hype5_audience |
productions | term slug |
hype5_profession |
people | term slug |
hype5_language |
productions | exact language text |
hype5_city |
productions, schedule | exact venue city |
hype5_company_status |
people | current, former, guest, none (no value counts as none) |
hype5_production, hype5_venue |
schedule | post ID |
hype5_date_from, hype5_date_to |
schedule | inclusive YYYY-MM-DD in the site time zone |
hype5_range |
schedule | today, week, month; takes precedence over dates |
hype5_access |
schedule | service or accessibility feature key |
hype5_status |
schedule | scheduled, sold_out, cancelled, postponed |
hype5_page |
all | page number; invalid input becomes page 1 |
Only scalar values are accepted. An attribute set on the shortcode always wins over the URL. A malformed hype5_production or hype5_venue makes the schedule empty instead of showing everything. Weeks start on WordPress's Week Starts On setting.
Which filter fields are shown is set in Appearance → Lists and pages (stored in hype5t_appearance as productions_filters, people_filters, schedule_filters).
Collection routes
| Collection | Built-in address |
|---|---|
| Productions | the hype5t_production archive (permalink base, default /productions/) |
| People | the hype5t_person archive (default /people/) |
| Schedule | home_url('/?hype5_collection=schedule') |
When a collection page is chosen in Appearance (option hype5t_collection_routes, keys productions, people, schedule ⇒ page ID), requests to the built-in address are redirected to that page with HTTP 302, keeping recognised hype5_* parameters. The page must be published and should contain the matching shortcode. A missing, unpublished or self-referencing page never causes a redirect. Single production and person pages are not affected.
Query services
Data\CollectionRequest::normalize(array $attributes = [], array $request = []): array
Combines attributes and request values (hype5_{key}) into a normalised argument array: context, search, genre, audience, language, city, profession, company_status, date_from, date_to, range, access, status (strings), production, venue (integers; -1 = malformed), page (≥ 1), per_page (1–100, default 12, alias limit), filters, pagination (booleans, default true) and active (whether any filter is set). Pass [] as $request to ignore the URL. Writes nothing.
Data\ProductionQuery::find(array $args): array
$args is the output of normalize() plus context (current, upcoming, archive, archived, active, all) and order (next, title, manual, premiere_asc, premiere_desc; resolve auto yourself). Returns ['items' => WP_Post[], 'total', 'page', 'pages', 'args']. Only published productions are returned, including password-protected ones; turn the posts into output with ProductionCard::batch() or Collections::render(), not by printing post fields.
ProductionQuery::states(string $context): array returns the repertory statuses of a context.
Data\ProductionQuery::next(array $ids): array
The next scheduled or sold-out performance of each production, keyed by the production IDs you pass. Performances are stored against the original-language production; translated IDs are resolved to it (Phase 5K). Productions the visitor may not see are left out (unpublished, or password-protected without the password entered). The rows are raw schedule rows; format them with Frontend\ProductionSchedule::row().
Data\PersonQuery::find(array $args): array
$args from normalize(), optionally with order (sort_name or title). Returns the same shape with person posts that are published, have a public profile and are shown in the directory. PersonQuery::sort_name(int $id): string returns the sort name or the title.
Data\ScheduleQuery::find(array $args = []): array and count(array $args = []): int
Arguments: limit (1–100, default 20), offset, production, venue, city, access, from, to, month, status, past, include_past. Invalid values throw \InvalidArgumentException. Returns raw performance rows with offers and replacement attached, or the matching count. Only performances of published original-language productions without a password are included, plus those of a password-protected production when the query is filtered to that production and the visitor has entered its password. The reader's-language version and the venue are not checked here; ProductionSchedule::row() withholds what the visitor may not see, and lists shown on other pages should keep only rows whose production is public to everyone (as Collections::render() does). Raw rows contain internal fields (internal note, attendance, timestamps) and must never be printed; format each row with Frontend\ProductionSchedule::row(). Do not pass the second (internal) argument of find(): it disables the publication checks.
ScheduleQuery::access_choices(): array returns the accepted access keys with labels.
Cards and rows for output
Frontend\ProductionCard::batch(array $ids, array $display): array— prepared production cards keyed by ID, as used bycollections.production-card.Frontend\ProductionSchedule::row(array $row, array $display, bool $registerAnchor = true): array— the preparedproduction.performanceview of a raw row, withheld when the visitor may not see it.Frontend\DisplayOptions::for_entity(int $id = 0, array $explicit = []): array— the$displayarray these functions need.
Example: the next dates of one production
A strip on a production's own page (scoped to that production, so the visitor's entered password applies):
use Hype5\Theater\Data\ScheduleQuery;
use Hype5\Theater\Frontend\{Appearance, DisplayOptions, ProductionSchedule, Render};
$productionId = get_the_ID();
$display = DisplayOptions::for_entity($productionId, ['schedule_layout' => 'agenda']);
try {
$rows = ScheduleQuery::find(['production' => $productionId, 'limit' => 5, 'status' => 'scheduled']);
} catch (\InvalidArgumentException $e) {
$rows = [];
}
echo '<div ' . Appearance::root($display, 'hype5-schedule') . '>';
foreach ($rows as $row) {
$view = ProductionSchedule::row($row, $display, false);
if (!empty($view['withheld'])) { continue; }
echo Render::template('production.performance', $view, $display);
}
echo '</div>';
For lists shown on other pages, and for complete lists with filters and pagination, use Collections::render('schedule', [...]) or [hype5_schedule]: they also leave out productions that are not public to everyone, and they load the plugin's stylesheets, which Render::template() alone does not.