The blogmenu plugin is a utility library designed to extract blog categories (controllers) and blog articles (controller methods) from your NanoMVC application. It uses structured metadata comments in both controllers and their methods.
$this->load->library('blogmenu');
$categories = $this->blogmenu->get_categories();
$articles = $this->blogmenu->get_articles();
At the top of your controller file, place the following metadata comment on the first line:
<?php // -> as categorie: { "name": "Category Name", "created": "2025-08-01 22:17" } ?>
name – The name of the blog categorycreated – The date the category was created (format: Y-m-d H:i)
For each method (must be public and not start with an underscore), add metadata in the PHPDoc using the
@blog tag:
/**
* @blog {
* "name": "Customize Core",
* "description": "Learn how to safely override NanoMVC core without affecting updates.",
* "created": "2025-07-15 19:00"
* }
*/
name – The menu titledescription – Optional summarycreated – Required timestamp (Y-m-d H:i)get_categories(?string $controller = null, string $order = 'created desc')Scans controller files and returns an array of categories (controllers) with parsed metadata.
$controller – Optional: scan only one controller$order – Sorting order by any metadata field (default: newest first)get_articles(?string $action = null, string $order = 'created desc', ?string $controller_name = null, ?string $act = null)Scans the methods of the current or another controller and returns all articles with their metadata.
$action – Optional: limit to a specific method$order – Sorting order (default: created desc)$controller_name – Optional: name of another controller to load$act – Optional: action name to pass when instantiating another controller
If $controller_name is provided, BlogMenu will try to load that controller from either the myapp or myfiles paths.
If not found, an exception will be thrown. When loaded, the controller will be instantiated with the given controller and action names, allowing metadata extraction from another controller's articles.
get_nav(array &$items, string $current): array
Returns pre and next items relative to the current article key.
$items – The array returned by get_articles()$current – The current method name[
'pre' => [ ... ], // previous article or empty array
'next' => [ ... ] // next article or empty array
]
pagination(array &$items, int $limit = 1): int|bool
Splits the list of articles into pages and adds a _page index to each article.
$items – The array returned by get_articles()$limit – Number of articles per page (must be positive)false if $limit is 0
Each article in $items gets a _page key with its page number.
Example: if limit is 3 and you have 8 articles, they will be marked with pages 1, 1, 1, 2, 2, 2, 3, 3.
name and created are required in both category and article metadataY-m-d H:i; invalid formats throw an exception