global_sidebars => {
type => "boolean",
examples => 1,
- description => "show sidebar page on all pages?"
+ description => "show sidebar page on all pages?",
safe => 1,
rebuild => 1,
},
my $content=shift;
shift;
- if (! defined $content) {
- error(gettext("sidebar content not specified"));
- }
-
my $page=$params{page};
return "" unless $page eq $params{destpage};
- my $file = $pagesources{$page};
- my $type = pagetype($file);
-
- $pagesidebar{$page}=
- IkiWiki::htmlize($page, $page, $type,
- IkiWiki::linkify($page, $page,
- IkiWiki::preprocess($page, $page,
- IkiWiki::filter($page, $page, $content))));
+
+ if (! defined $content) {
+ $pagesidebar{$page}=undef;
+ }
+ else {
+ my $file = $pagesources{$page};
+ my $type = pagetype($file);
+
+ $pagesidebar{$page}=
+ IkiWiki::htmlize($page, $page, $type,
+ IkiWiki::linkify($page, $page,
+ IkiWiki::preprocess($page, $page,
+ IkiWiki::filter($page, $page, $content))));
+ }
return "";
}
sub sidebar_content ($) {
my $page=shift;
- return $pagesidebar{$page} if exists $pagesidebar{$page};
+ return $pagesidebar{$page} if defined $pagesidebar{$page};
- return if defined $config{global_sidebars} && !$config{global_sidebars};
+ return if ! exists $pagesidebar{$page} &&
+ defined $config{global_sidebars} && ! $config{global_sidebars};
my $sidebar_page=bestlink($page, "sidebar") || return;
my $sidebar_file=$pagesources{$sidebar_page} || return;
The `sidebar` directive is supplied by the [[!iki plugins/sidebar desc=sidebar]] plugin.
-This directive specifies a custom sidebar to display on the page,
+This directive can specify a custom sidebar to display on the page,
overriding any sidebar that is displayed globally.
+If no custom sidebar content is specified, it forces the sidebar page to
+be used as the sidebar, even if the `global_sidebars` setting has been
+used to disable use of the sidebar page by default.
+
## examples
\[[!sidebar """
\[[!calendar pages="posts/*"]]
"""]]
+ \[[!sidebar]]
+
[[!meta robots="noindex, follow"]]