"Sidebar", "version" => "0.3.2", "author" => "Starbeamrainbowlabs", "description" => "Adds a sidebar to the left hand side of every page. Add '\$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.", "id" => "extra-sidebar", "code" => function() { global $settings; $show_sidebar = false; // Show the sidebar if it is enabled in the settings if(isset($settings->sidebar_show) && $settings->sidebar_show === true) $show_sidebar = true; // Also show and persist the sidebar if the special GET parameter // sidebar is seet if(!$show_sidebar && isset($_GET["sidebar"])) { $show_sidebar = true; // Set a cookie to persist the display of the sidebar send_cookie("sidebar_show", "true", time() + (60 * 60 * 24 * 30)); } // Show the sidebar if the cookie is set if(!$show_sidebar && isset($_COOKIE["sidebar_show"])) $show_sidebar = true; // Delete the cookie and hide the sidebar if the special GET paramter // nosidebar is set if(isset($_GET["nosidebar"])) { $show_sidebar = false; unset($_COOKIE["sidebar_show"]); send_cookie("sidebar_show", null, time() - 3600); } page_renderer::register_part_preprocessor(function(&$parts) use ($show_sidebar) { global $settings, $pageindex, $env; // Don't render a sidebar if the user is logging in and a login is // required in order to view pages. if($settings->require_login_view && in_array($env->action, [ "login", "checklogin" ])) return false; if($show_sidebar && !isset($_GET["printable"])) { // Show the sidebar $exec_start = microtime(true); // Sort the pageindex $sorted_pageindex = get_object_vars($pageindex); $sorter = new Collator(""); uksort($sorted_pageindex, function($a, $b) use($sorter) : int { return $sorter->compare($a, $b); }); $sidebar_contents = ""; $sidebar_contents .= render_sidebar($sorted_pageindex); $parts["{body}"] = "
$settings->sitename has an optional sidebar which displays a list of all the current pages and their respective subpages that it is currently hosting in a tree like structure. It may or may not be enabled.
If it isn't enabled, it can be enabled for your current browser only by appending sidebar=yes
to the current page's query string.
If it is enabled, it can be disabled for your current browser only by appending nosidebar
to the current page's query string.