From 5ab7b9597b2a29b1c342c87f51dafec5820dc327 Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Fri, 4 Oct 2024 09:58:21 +0100 Subject: [PATCH] refactored playlists by-date use of template factory to superclass --- ui/MenuItem.php | 6 ++++-- ui/Playlists.php | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/MenuItem.php b/ui/MenuItem.php index 4e504f27..5ee04452 100644 --- a/ui/MenuItem.php +++ b/ui/MenuItem.php @@ -123,9 +123,11 @@ public function dispatchSubaction($action, $subaction, $extra=0) { } } - public function render() { + public function render($block = null) { $templateFact = new TemplateFactoryUI(); $template = $templateFact->load($this->getTemplate()); - return $template->render($this->getTemplateVars()); + return $block ? + $template->renderBlock($block, $this->getTemplateVars()) : + $template->render($this->getTemplateVars()); } } diff --git a/ui/Playlists.php b/ui/Playlists.php index 8101fa6f..b7b50532 100644 --- a/ui/Playlists.php +++ b/ui/Playlists.php @@ -805,11 +805,9 @@ public function handlePlaylistsByDate() { foreach($lists as &$list) $list['timerange'] = self::timeToLocale($list['showtime']); - $factory = new TemplateFactoryUI(); - $template = $factory->load('list/bydate.html'); - $tbody = $template->renderBlock('list', [ - "lists" => $lists - ]); + $this->setTemplate('list/bydate.html'); + $this->addVar('lists', $lists); + $tbody = $this->render('list'); echo json_encode(["count" => $count, "tbody" => $tbody]); }