From: Wendall C. <wen...@83...> - 2004-05-25 18:10:39
|
Yesterday I worked with Mike on the debug theme. He asked that a couple things happen. First, the <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> needs to go away if the document is treated as an xml file. Secondly, he asked that stylesheets be added to the theme. The details are here: http://www.w3.org/TR/xml-stylesheet/ While the change is fairly simple on the surface, one problem arose. The stylesheets are moved from the document into the headers. Since I can't access the {STYLE} tag via theme.php I chose to eliminate it and add a tag called {STYLESHEETS}. This would obviously be unnecessary if done within Layout. Here is the code I used: theme.php <?php if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")){ @header("Content-Type: application/xhtml+xml; charset=UTF-8"); $THEME["XML"] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $THEME["XML_STYLE"] = set_style(); $THEME["XML_ALT_STYLE"] = ''; $THEME["DOCTYPE"] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"; $THEME["HTML"] = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\">"; } else { @header("Content-Type: text/html; charset=UTF-8"); $THEME["DOCTYPE"] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"; $THEME["HTML"] = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"; $THEME["STYLESHEET"] = "<link rel=\"stylesheet\" href=\"" .$_SESSION["OBJ_layout"]->theme_address."style.css\" type=\"text/css\"?>"; } $_SESSION["OBJ_layout"]->meta_content = FALSE; function set_style(){ $alt_css = $_SESSION["OBJ_layout"]->theme_dir."browsers.txt"; $css = ''; if (file_exists($alt_css)){ $altStyles = file($alt_css); fore<?php if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")){ @header("Content-Type: application/xhtml+xml; charset=UTF-8"); $THEME["XML"] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $THEME["XML_STYLE"] = set_style(); $THEME["XML_ALT_STYLE"] = ''; $THEME["DOCTYPE"] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"; $THEME["HTML"] = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\">"; } else { @header("Content-Type: text/html; charset=UTF-8"); $THEME["DOCTYPE"] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"; $THEME["HTML"] = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"; $THEME["STYLESHEET"] = "<link rel=\"stylesheet\" href=\"" .$_SESSION["OBJ_layout"]->theme_address."style.css\" type=\"text/css\"?>"; } $_SESSION["OBJ_layout"]->meta_content = FALSE; function set_style(){ $alt_css = $_SESSION["OBJ_layout"]->theme_dir."browsers.txt"; $css = ''; if (file_exists($alt_css)){ $altStyles = file($alt_css); foreach ($altStyles as $style){ $temp = explode("::", $style); if (preg_match("/".$temp[0]."/", $_SERVER["HTTP_USER_AGENT"]) && file_exists($_SESSION["OBJ_layout"]->theme_dir.trim($temp[1]))){ $css .= "<?xml-stylesheet alternate=\"yes\" title=\"compact\" href=\"" . $_SESSION["OBJ_layout"]->theme_address . trim($temp[1]) . "\" type=\"text/css\" ?>\n"; $browser_css = 1; break; } } } if (!isset($browser_css) && file_exists($_SESSION["OBJ_layout"]->theme_dir."style.css")) $css = "<?xml-stylesheet href=\"".$_SESSION["OBJ_layout"]->theme_address. "style.css\" type=\"text/css\"?>"; return $css; } ?>ach ($altStyles as $style){ $temp = explode("::", $style); if (preg_match("/".$temp[0]."/", $_SERVER["HTTP_USER_AGENT"]) && file_exists($_SESSION["OBJ_layout"]->theme_dir.trim($temp[1]))){ $css .= "<?xml-stylesheet alternate=\"yes\" title=\"compact\" href=\"" . $_SESSION["OBJ_layout"]->theme_address . trim($temp[1]) . "\" type=\"text/css\" ?>\n"; $browser_css = 1; break; } } } if (!isset($browser_css) && file_exists($_SESSION["OBJ_layout"]->theme_dir."style.css")) $css = "<?xml-stylesheet href=\"".$_SESSION["OBJ_layout"]->theme_address. "style.css\" type=\"text/css\"?>"; return $css; } ?> theme.tpl would then include: {XML} {XML_STYLE} {XML_ALT_STYLE} {DOCTYPE} {HTML} {STYLESHEET} <!-- Replaced {STYLE} with {STYLESHEET} --> HTH, Wendall On Tue, 2004-05-25 at 10:34, Matthew McNaney wrote: > While working on javascript detection, I came across another tag I would > need to add to all themes. > > Here are the tags that ride in the header of every theme: > > DOCTYPE > TITLE > METATAGS > JAVASCRIPT > STYLE > > Plus, as I said, I want to add a specific command to the body tag to > help check for javascript availability. > > So this is what I propose: > Themes in 0.9.4 will consist of what happens between <body> and </body> > > This will allow us flexibility in the future and prevent people from > having to change their themes for new features. The <html><head><body> > portion will be one template file that crosses with all themes. > > I am interested in your response. > > Thanks, > Matt -- "Only the ideas that we really live have any value." --Hermann Hesse (Demian) |