aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-11 18:39:32 +0200
committerThomas Lange <code@nerdmind.de>2021-07-11 18:39:32 +0200
commit42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34 (patch)
tree345e77f89394f88b7dd2b2dcd5d1f241f56aa7d3 /core
parent29ae2e684677944d27d2d78d36c89b532fc8a05b (diff)
downloadblog-42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34.tar.gz
blog-42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34.tar.xz
blog-42da9bd4bb6d35706ee5fefd3bac9b60ac5ada34.zip
Add template function to get data from a category
Diffstat (limited to 'core')
-rw-r--r--core/functions.php19
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');