From 42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 11 Jul 2021 18:39:32 +0200 Subject: Add template function to get data from a category --- core/functions.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'core/functions.php') diff --git a/core/functions.php b/core/functions.php index f1472ca..ffcb488 100644 --- a/core/functions.php +++ b/core/functions.php @@ -433,7 +433,20 @@ function generateSlug($string, $separator = '-') { } #=============================================================================== -# Function to get data from specific page in templates +# Function for use in templates to get data of a category +#=============================================================================== +function CATEGORY(int $id): array { + $Repository = Application::getRepository('Category'); + + if($Category = $Repository->find($id)) { + return generateItemTemplateData($Category); + } + + return []; +} + +#=============================================================================== +# Function for use in templates to get data of a page #=============================================================================== function PAGE(int $id): array { $Repository = Application::getRepository('Page'); @@ -446,7 +459,7 @@ function PAGE(int $id): array { } #=============================================================================== -# Function to get data from specific post in templates +# Function for use in templates to get data of a post #=============================================================================== function POST(int $id): array { $Repository = Application::getRepository('Post'); @@ -459,7 +472,7 @@ function POST(int $id): array { } #=============================================================================== -# Function to get data from specific user in templates +# Function for use in templates to get data of a user #=============================================================================== function USER(int $id): array { $Repository = Application::getRepository('User'); -- cgit v1.2.3