/** * List of episode contributors * * **Examples** * * Iterating over a list of contributors * * ```jinja * {% for contributor in episode.contributors %} * {{ contributor.name }} * {% if not loop.last %}, {% endif %} * {% endfor %} * ``` * * Iterating over a grouped list of contributors * * ```jinja * {% for contributorGroup in episode.contributors({groupby: "group"}) %} * <strong>{{ contributorGroup.group.title }}:</strong> * {% for contributor in contributorGroup.contributors %} * {{ contributor.name }} * {% if not loop.last %}, {% endif %} * {% endfor %} * {% endfor %} * ``` * * **Parameters** * * - **id:** Fetch one contributor by its id. * Example: `episode.contributors({id: 'james'}).name` * - **group:** group slug. If none is given, show all contributors. * - **role:** role slug. If none is given, show all contributors. * - **groupby:** group or role slug. Group by "group" or "role". * If used, the returned data is has another layer for the groups. * See examples for more details. * - **order:** Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'ASC'. * - 'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c). * - 'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a). * - **orderby:** Sort contributors by parameter. Defaults to 'position'. * - 'position' - Order by the contributors position in the episode. * - 'comment' - Order by the contributors comment in the episode. * * @accessor * @dynamicAccessor episode.contributors */ public static function accessorEpisodeContributors($return, $method_name, $episode, $post, $args = array()) { return $episode->with_blog_scope(function () use($return, $method_name, $episode, $post, $args) { $defaults = array('order' => 'ASC', 'orderby' => 'position'); $args = wp_parse_args($args, $defaults); $contributions = EpisodeContribution::find_all_by_episode_id($episode->id); $contributions = \Podlove\Modules\Contributors\Contributors::orderContributions($contributions, $args); return \Podlove\Modules\Contributors\Contributors::filterContributions($contributions, $args); }); }