aboutsummaryrefslogtreecommitdiffstats
path: root/theme/admin/html/post/form.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-01 20:11:34 +0200
committerThomas Lange <code@nerdmind.de>2021-07-01 20:11:34 +0200
commite6cef37e0c782fe770db20888d99c17d10e2c479 (patch)
treeaed0790a0fa8eb7cceef7bb32aef4f69b724d619 /theme/admin/html/post/form.php
parentf0ea19767d502ec7b5afff7c66c2681292175a3b (diff)
downloadblog-e6cef37e0c782fe770db20888d99c17d10e2c479.tar.gz
blog-e6cef37e0c782fe770db20888d99c17d10e2c479.tar.xz
blog-e6cef37e0c782fe770db20888d99c17d10e2c479.zip
Add category system to categorize posts (readme)
This commit implements a new category system to categorize posts. Each category can have an unlimited number of nested children categories. A single post don't necessarily need to be in a category, but it can. Each category can have a full content body like posts or pages, so you have enough space to describe the content of your categories. Please note that you need to have at least the following MySQL/MariaDB versions to use the category system, because it uses "WITH RECURSIVE" database queries, the so-called "Common-Table-Expressions (CTE)". MariaDB: 10.2.2 MySQL: 8.0 See: https://mariadb.com/kb/en/with/ See: https://dev.mysql.com/doc/refman/8.0/en/with.html
Diffstat (limited to 'theme/admin/html/post/form.php')
-rw-r--r--theme/admin/html/post/form.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/theme/admin/html/post/form.php b/theme/admin/html/post/form.php
index 346d6f4..4ae07bd 100644
--- a/theme/admin/html/post/form.php
+++ b/theme/admin/html/post/form.php
@@ -1,3 +1,18 @@
+<?php
+function categorySelectList($category_tree, $selected = NULL, $prefix = '') {
+ foreach($category_tree as $category) {
+ $option = '<option value="%s"%s>%s%s [%d]</option>';
+ $select = ($category['ID'] == $selected) ? ' selected' : '';
+
+ printf($option, $category['ID'], $select, $prefix, escapeHTML($category['NAME']), $category['ID']);
+
+ if(isset($category['CHILDS'])) {
+ # If there are children, call self and pass children array.
+ (__FUNCTION__)($category['CHILDS'], $selected, $prefix.'– ');
+ }
+ }
+}
+?>
<?php if($FORM['INFO']): ?>
<div id="message-list-wrapper">
<ul id="message-list">
@@ -16,7 +31,7 @@
<label for="form_name">
<i class="fa fa-newspaper-o"></i><?=$Language->text('label_name')?></label>
- <div class="form-grid-item first">
+ <div class="form-grid-item">
<input id="form_name" name="name" value="<?=escapeHTML($FORM['DATA']['NAME'])?>" />
</div>
@@ -27,6 +42,16 @@
<input id="form_slug" name="slug" value="<?=escapeHTML($FORM['DATA']['SLUG'])?>" />
</div>
+ <label for="form_category">
+ <i class="fa fa-tag"></i><?=$Language->text('label_category')?></label>
+
+ <div class="form-grid-item">
+ <select id="form_category" name="category">
+ <option value="">[ –– <?=$Language->text('label_category')?> –– ]</option>
+ <?=categorySelectList($FORM['CATEGORY_TREE'], $FORM['DATA']['CATEGORY']);?>
+ </select>
+ </div>
+
<label for="form_user">
<i class="fa fa-user"></i><?=$Language->text('label_user')?></label>