I do not claim to know anything much about PHP, this is really quite a hack on my own part and I’m betting there are better ways to do it (more robust, less code to change, etc). I’d love to hear your comments on this. I’ve just been wanting to do dynamic menus and a common header (at the least) across all my diverse web applications (gallery, blog, wiki, etc).
Brian says: See.. just leave a comment like this! It’s easy.
On my brianwiese.net website document root, all pages include:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Brian Wiese">
<meta name="Description" content="brianwiese.net homepage website">
<meta name="Keywords" content="brian wiese, homepage, website, gnu, linux, geek, nerd, clever, smart, hacker, gnu, linux, peace, love, photos">
<title>Brian Wiese - Homepage</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- <link rel="icon" href="logo/lvs-16.png" type="image/png"> -->
<link rel="home" title="Home" href="index.html">
<link rel="stylesheet" type="text/css" href="/css/base/content.css" media="all">
<link rel="stylesheet" type="text/css" href="/css/base/template.css" media="screen">
<link rel="stylesheet" type="text/css" href="/css/cavendish/content.css" title="Cavendish" media="all">
<link rel="stylesheet" type="text/css" href="/css/cavendish/template.css" title="Cavendish" media="screen">
<link rel="stylesheet" type="text/css" href="/css/cavendish/home.css" title="Cavendish" media="screen">
<?php include("dynmenu-head.php"); ?>
<!-- Dynamic Menu, http://codex.wordpress.org/Dynamic_Menu_Highlighting -->
<?php
$loc = getenv('SCRIPT_NAME');
if ( preg_match("/^\/links/", $loc) ) { $curr = 'links'; }
elseif ( preg_match("/^\/wiki/", $loc) ) { $curr = 'wiki'; }
elseif ( preg_match("/^\/blog/", $loc) ) { $curr = 'blog'; }
elseif ( preg_match("/^\/photos/", $loc) ) { $curr = 'photos'; }
elseif ( preg_match("/^\/about/", $loc) ) { $curr = 'about'; }
else { $curr = 'home'; }
?>
<style type="text/css">
#header ul a#<?php echo $curr; ?> {
color: yellow;
}
#header ul a.out {
font-weight: normal;
}
</style>
<a name="top"> <div id="header"> <h1><a href="/" title="Back to home page" accesskey="1">NO TEXT</a></h1> <ul> <li id="links"><a class="out" href="http://del.icio.us/bwiese" title="bwiese's del.icio.us links">Links</a></li> <!-- <li><a href="/norway/" title="brian's semester in Norway">Norway</a></li> --> <!-- <li><a href="/misc/" title="misc and old things">Misc</a></li> --> <li id="l_wiki"><a id="wiki" class="out" href="/wiki/" title="wiki notes howtos docs">Wiki</a></li> <li id="l_blog"><a id="blog" class="out" href="/blog/" title="brian's views and activities">Blog</a></li> <li id="l_photos"><a id="photos" href="/photos/" title="a slight obsession with photography">Photos</a></li> <li id="l_about"><a id="about" href="/about/" title="info on brian and this site">About</a></li> <li id="l_home"><a id="home" href="/" title="brian's homepage">Home</a></li> </ul> <form id="search" method="get" action="http://www.google.com/custom" title="search brianwiese.net"> <div> <label for="q" title="Search this site">Google this site: </label> <input type="hidden" name="domains" value="brianwiese.net"> <input type="hidden" name="sitesearch" value="brianwiese.net"> <input id="q" type="text" name="q" size="30" value=""> <input id="submit" type="submit" value="Go"> <input type="hidden" name="forid" value="1"></input> </div> </form> </div> <!-- end header -->
Discovered “html_wrap” directory after reading Upgrading Gallery 1
...
// $Id: album.header.default,v 1.19 2005/08/15 23:01:22 jenst Exp $
?>
<?php
includeHtmlWrap("wrapper.header");
/* changes by Brian Wiese */
include("../inc/headtext.php");
include("../inc/header.php");
include("../inc/dynmenu-head.php");
/* end changes by Brian Wiese */
if (!includeTemplate('album.header.tpl')) {
...
In brianwiese.net/photos/ Gallery v1 installation, I did not find a quick theme/template to edit 1), so I edited the following files:
function common_header() {
// Do some meta tags
metatags();
// Import CSS Style_sheet
echo getStyleSheetLink();
// Set the Gallery Icon
echo "\n <link rel=\"shortcut icon\" href=\"". makeGalleryUrl('images/favicon.ico') . "\">\n";
// added for common header menu by bkw Brian Wiese
$includefile = '../inc/headtext.php';
$rval = readfile($includefile);
}
<html>
<head>
<title><?php echo $gallery->app->galleryTitle ?></title>
<?php
common_header() ;
echo "<!-- Dynamic menu include, in albums.php -->";
include("../inc/dynmenu-head.php");
</head>
<body dir="<?php echo $gallery->direction ?>">
<!-- modification by bkw, brian wiese -->
<? include ("../inc/header.php"); ?>
<!-- end modification by bkw -->