update sidebar & themes
This commit is contained in:
1 parent
25dad8631e
commit
09e003f88a
3 files changed
+58
-17
No files matched your search
@@ -17,23 +17,59 @@
|
|||||||
// (Popeye-style) while keeping the other plugins in the right sidebar.
|
// (Popeye-style) while keeping the other plugins in the right sidebar.
|
||||||
// Mirrors Bludit's own Theme::plugins() loop, but captures the output.
|
// Mirrors Bludit's own Theme::plugins() loop, but captures the output.
|
||||||
global $plugins;
|
global $plugins;
|
||||||
$sidebarSearchHtml = '';
|
$sidebarSearchHtml = ''; // search box, rendered under the hero on the homepage
|
||||||
$sidebarOtherHtml = '';
|
$sidebarItems = array(); // every sidebar plugin, to be sorted into a fixed order
|
||||||
|
$sidebarIndex = 0;
|
||||||
if (isset($plugins['siteSidebar'])) {
|
if (isset($plugins['siteSidebar'])) {
|
||||||
foreach ($plugins['siteSidebar'] as $plugin) {
|
foreach ($plugins['siteSidebar'] as $plugin) {
|
||||||
$out = $plugin->siteSidebar();
|
$out = $plugin->siteSidebar();
|
||||||
if (strpos($out, 'plugin-search') !== false) {
|
|
||||||
|
$isSearch = (strpos($out, 'plugin-search') !== false);
|
||||||
|
$isNav = (strpos($out, 'plugin-navigation') !== false || strpos($out, 'plugin-pages') !== false);
|
||||||
|
|
||||||
|
// Fixed sidebar order (lower = higher up). Unknown plugins such as
|
||||||
|
// the Hit Counter default to 90, i.e. pinned to the bottom.
|
||||||
|
$priority = 90;
|
||||||
|
if (strpos($out, 'plugin-about') !== false) $priority = 10; // Blog / About
|
||||||
|
elseif ($isSearch) $priority = 20; // Search
|
||||||
|
elseif ($isNav) $priority = 30; // Navigation
|
||||||
|
elseif (strpos($out, 'plugin-categories') !== false) $priority = 40; // Category
|
||||||
|
|
||||||
|
if ($isSearch) {
|
||||||
$sidebarSearchHtml .= $out;
|
$sidebarSearchHtml .= $out;
|
||||||
} else {
|
|
||||||
// Mark the navigation / pages plugin so its list can be
|
|
||||||
// shuffled client-side (see the script near the body end).
|
|
||||||
if (strpos($out, 'plugin-navigation') !== false || strpos($out, 'plugin-pages') !== false) {
|
|
||||||
$out = '<div class="js-random-nav">' . $out . '</div>';
|
|
||||||
}
|
|
||||||
$sidebarOtherHtml .= $out;
|
|
||||||
}
|
}
|
||||||
|
// Mark the navigation / pages plugin so its list can be shuffled
|
||||||
|
// client-side (see the script near the body end).
|
||||||
|
if ($isNav) {
|
||||||
|
$out = '<div class="js-random-nav">' . $out . '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sidebarItems[] = array(
|
||||||
|
'priority' => $priority,
|
||||||
|
'index' => $sidebarIndex++,
|
||||||
|
'search' => $isSearch,
|
||||||
|
'html' => $out,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stable sort by priority, then original order (PHP < 8 usort isn't stable).
|
||||||
|
usort($sidebarItems, function ($a, $b) {
|
||||||
|
if ($a['priority'] === $b['priority']) {
|
||||||
|
return $a['index'] - $b['index'];
|
||||||
|
}
|
||||||
|
return $a['priority'] - $b['priority'];
|
||||||
|
});
|
||||||
|
|
||||||
|
$sidebarFullHtml = ''; // all plugins, ordered (used off the homepage)
|
||||||
|
$sidebarNoSearchHtml = ''; // same, minus search (used on the homepage)
|
||||||
|
foreach ($sidebarItems as $item) {
|
||||||
|
$sidebarFullHtml .= $item['html'];
|
||||||
|
if (!$item['search']) {
|
||||||
|
$sidebarNoSearchHtml .= $item['html'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The hero (and the relocated search) only appear on the blog front page.
|
// The hero (and the relocated search) only appear on the blog front page.
|
||||||
$heroVisible = ($WHERE_AM_I === 'home' && Paginator::currentPage() == 1);
|
$heroVisible = ($WHERE_AM_I === 'home' && Paginator::currentPage() == 1);
|
||||||
?>
|
?>
|
||||||
|
|||||||
+6
-2
@@ -36,8 +36,12 @@
|
|||||||
<!-- Include CSS Bootstrap ICONS file from Bludit Core -->
|
<!-- Include CSS Bootstrap ICONS file from Bludit Core -->
|
||||||
<?php echo Theme::cssBootstrapIcons(); ?>
|
<?php echo Theme::cssBootstrapIcons(); ?>
|
||||||
|
|
||||||
<!-- Include CSS Styles from this theme -->
|
<!-- Include CSS Styles from this theme (cache-busted by file mtime) -->
|
||||||
<?php echo Theme::css('css/style.css'); ?>
|
<?php
|
||||||
|
$styleVersion = @filemtime(THEME_DIR_CSS . 'style.css');
|
||||||
|
$styleHref = DOMAIN_THEME . 'css/style.css' . ($styleVersion ? '?v=' . $styleVersion : '');
|
||||||
|
?>
|
||||||
|
<link rel="stylesheet" type="text/css" href="<?php echo $styleHref; ?>">
|
||||||
|
|
||||||
<!-- Load Bludit Plugins: Site head -->
|
<!-- Load Bludit Plugins: Site head -->
|
||||||
<?php Theme::plugins('siteHead'); ?>
|
<?php Theme::plugins('siteHead'); ?>
|
||||||
+6
-5
@@ -18,13 +18,14 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// On the homepage front page the search box is shown under the hero,
|
// Plugins are rendered in a fixed order (see index.php):
|
||||||
// so only render the remaining sidebar plugins here. Everywhere else
|
// Blog/About > Search > Navigation > Category > … > Hit Counter (bottom)
|
||||||
// the sidebar shows the full set (search included).
|
// On the homepage front page the search box is shown under the hero, so
|
||||||
|
// it is omitted from the sidebar there.
|
||||||
if ($heroVisible) {
|
if ($heroVisible) {
|
||||||
echo $sidebarOtherHtml;
|
echo $sidebarNoSearchHtml;
|
||||||
} else {
|
} else {
|
||||||
echo $sidebarSearchHtml . $sidebarOtherHtml;
|
echo $sidebarFullHtml;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</aside>
|
</aside>
|
||||||
Reference in new issue
Block a user