/** * Network Lists * * List network lists. * Use the `slug` parameter to access a specific list. * * **Examples** * * Iterate over all lists. * * ```jinja * {% for list in network.lists %} * {{ list.title }} * {% endfor %} * ``` * * Access a specific list by id. * * ```jinja * {{ network.lists({id: "example"}).title }} * ``` * * @see list * @accessor */ public function lists($args = []) { NetworksModel\PodcastList::activate_network_scope(); if (isset($args['id'])) { if ($list = NetworksModel\PodcastList::find_one_by_slug($args['id'])) { return new NetworksTemplate\PodcastList($list); } } $lists = []; foreach (NetworksModel\PodcastList::all() as $list) { $lists[] = new PodcastList($list); } NetworksModel\PodcastList::deactivate_network_scope(); return $lists; }
public function prepare_items() { // define column headers $columns = $this->get_columns(); $hidden = array(); $sortable = false; $this->_column_headers = array($columns, $hidden, $sortable); PodcastList::activate_network_scope(); $items = \Podlove\Modules\Networks\Model\PodcastList::all(); PodcastList::deactivate_network_scope(); uasort($items, function ($a, $b) { return strnatcmp($a->title, $b->title); }); $this->items = $items; }