get_post($post_id);
$categories = $wiki->category_tree();
$breadcrumbs = Render::all_breadcrumbs($categories);
if ($post == false) { // when post not found
$post = [ // create a virtual record with error messages
'id' => 0,
'title' => 'Το άρθρο που αναζητήσατε δεν υπάρχει',
'category_id' => 0,
'intro' => 'Για να βρειτε το άρθρο που ψάχνετε χρησιμοποιήστε την αναζήτηση
του wiki ή πλοηγηθείτε στο δέντρο των κατηγοριών.',
'body' => ""
];
} else { // post found; prepare article's data to render
$category_id = $post['category_id'];
// find parent_ids of current category (to open the menu tree)
$category_path = [];
foreach($breadcrumbs[$category_id]['parents'] as $parent) {
$category_path[] = intval($parent['id']);
}
$category_path[] = intval($category_id);
}
// format special parts of post
$parsedown = new Parsedown();
$body_html = $parsedown->text($post['body']); // body: markdown to html
// decode json output (tags + medias)
if ($post['tags_json'] != null) { $tags = json_decode($post['tags_json']); }
if ($post['medias_json'] != null) { $medias = json_decode($post['medias_json']); }
// then render the page ...
// -----------------------------------------------------------------------------
?>
$post['category_id'],
'title' => $breadcrumbs[ $post['category_id'] ]['rec']['title'],
'parents' => $breadcrumbs[ $post['category_id'] ]['parents']
]); ////////////////////////////////////////////////////
?>
$categories,
'open_path' => (($post['id'] == 0)
? [1,2,3] // post not exist; open main categories
: $category_path) // post exists: open category path
]); ////////////////////////////////////////////////////
?>
=$post['title']?>
Δημοσίευση: =Render::date_friendly($post['creation_date'])?>
— Τελευταία Ενημέρωση: =Render::date_friendly($post['update_date'])?>
=$post['intro']?>
=$body_html?>