PHP code example of tryhackx / flarum-advanced-pages
1. Go to this page and download the library: Download tryhackx/flarum-advanced-pages library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// A nested <ul> menu of everything under /p/docs (visibility-aware).
function ap_menu(array $nodes): void {
if (!$nodes) return;
echo '<ul>';
foreach ($nodes as $node) {
$p = $node['page'];
printf('<li><a href="/p/%s">%s</a>',
htmlspecialchars($p->slug), htmlspecialchars($p->title));
ap_menu($node['children']); // recurse into children
echo '</li>';
}
echo '</ul>';
}
ap_menu($pages->tree('docs'));