From a1c0d416814bff336a83626c8c8c32331b82f00f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 18 May 2003 13:22:00 +0000 Subject: [PATCH] - Added option to control placement of sidebar(s). --- themes/xtemplate/xtemplate.theme | 40 ++++++++++++++++++++++++++++---- themes/xtemplate/xtemplate.xtmpl | 7 +++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/themes/xtemplate/xtemplate.theme b/themes/xtemplate/xtemplate.theme index d0bf0c053ab..60d51406f89 100644 --- a/themes/xtemplate/xtemplate.theme +++ b/themes/xtemplate/xtemplate.theme @@ -1,11 +1,12 @@ t("No sidebars"), "left" => t("Sidebar on the left"), "right" => t("Sidebar on the right"), "both" => t("Sidebar on the left and the right"))); + $output .= form_textarea("Message on front page", "xtemplate_message", variable_get("xtemplate_message", "edit message"), 70, 6, "This text will be displayed on the front page. It can be used to display a mission statement, announcement or site description.."); $output .= form_textarea("Primary links", "xtemplate_primary_links", variable_get("xtemplate_primary_links", l("edit primary links", "admin/system/themes/xtemplate")), 70, 6, "The primary links."); $output .= form_textarea("Secondary links", "xtemplate_secondary_links", variable_get("xtemplate_secondary_links", l("edit secondary links", "admin/system/themes/xtemplate")), 70, 6, "The secondary links."); $output .= form_select("Search box", "xtemplate_search_box", variable_get("xtemplate_search_box", 0), array(t("Disabled"), t("Enabled")), "Show a search box in the upper right corner."); - return $output; + return $output; } class Theme_xtemplate extends BaseTheme { @@ -22,6 +23,8 @@ class Theme_xtemplate extends BaseTheme { include_once("themes/xtemplate/xtemplate.inc"); } + $this->sidebar = variable_get("xtemplate_sidebar", "right"); + $this->template = new XTemplate("themes/xtemplate/xtemplate.xtmpl"); $this->template->SetNullBlock(" "); // "" doesnt work! } @@ -80,6 +83,7 @@ class Theme_xtemplate extends BaseTheme { "primary_links" => variable_get("xtemplate_primary_links", l("edit primary links", "admin/system/themes/xtemplate")), "secondary_links" => variable_get("xtemplate_secondary_links", l("edit secondary links", "admin/system/themes/xtemplate")) )); + if (variable_get("xtemplate_search_box", 1)) { $this->template->assign(array( //"search" => search_form(), @@ -94,8 +98,26 @@ class Theme_xtemplate extends BaseTheme { $this->template->parse("header.message"); } + ob_start(); + + if ($this->sidebar == "left") { + theme_blocks("all"); + } + else if ($this->sidebar == "both") { + theme_blocks("left"); + } + + if ($blocks = ob_get_contents()) { + $this->template->assign("blocks", $blocks); + $this->template->parse("header.blocks"); + } + + ob_end_clean(); + $this->template->parse("header"); print $this->template->text("header"); + + } function block($title, $content, $region = "main") { @@ -122,15 +144,23 @@ class Theme_xtemplate extends BaseTheme { } function footer() { - // unfortunately, theme_blocks PRINTS the blocks instead of RETURNING them. - // so we need some output buffering + ob_start(); - theme_blocks("all"); + + if ($this->sidebar == "right") { + theme_blocks("all"); + } + else if ($this->sidebar == "both") { + theme_blocks("right"); + } + if ($blocks = ob_get_contents()) { $this->template->assign("blocks", $blocks); $this->template->parse("footer.blocks"); } + ob_end_clean(); + $this->template->assign( array( "footer_message" => variable_get("site_footer", ""), "footer" => theme_footer() diff --git a/themes/xtemplate/xtemplate.xtmpl b/themes/xtemplate/xtemplate.xtmpl index 287739d4278..f8be0756bd8 100644 --- a/themes/xtemplate/xtemplate.xtmpl +++ b/themes/xtemplate/xtemplate.xtmpl @@ -32,11 +32,16 @@ + + +
{header_message}
-
+