diff options
author | Thomas Lange <code@nerdmind.de> | 2021-07-11 18:39:32 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-07-11 18:39:32 +0200 |
commit | 42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34 (patch) | |
tree | 345e77f89394f88b7dd2b2dcd5d1f241f56aa7d3 /core/functions.php | |
parent | 29ae2e684677944d27d2d78d36c89b532fc8a05b (diff) | |
download | blog-42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34.tar.gz blog-42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34.tar.xz blog-42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34.zip |
Add template function to get data from a category
Diffstat (limited to 'core/functions.php')
-rw-r--r-- | core/functions.php | 19 |
1 files changed, 16 insertions, 3 deletions
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'); |