Loads a stylesheet with dynamic values dependent on the Page view
Sets the sidebar photo appropriate for a section of the site by determining the parent Page of the subpage.
Copy this code and paste it in your HTML
/*** file: header.php ******************************/
<link rel="stylesheet" type="text/css" media="screen" href="<?php
//Import stylesheet for the different pages
if ( is_frontpage
() || is_page
('index') ||
preg_match( "#/index/#i" , $_SERVER['REQUEST_URI']) ) { print getdir
().'/home.css';
}
else {
echo getdir
().'/sub.css.php?p=';
if ( is_home
() || is_single
() || is_archive
() ||
preg_match("#/blog/#i",$_SERVER['REQUEST_URI']) ) else {
$post_parent = get_post($post->post_parent);
print $post_parent->post_name;
}
}
?>" />
/*** file: sub.css.php ******************************/
<?php header('Content-type: text/css');
?>
div#sidebar_photo {
background-image: url("images/sidebar_photo<?php
if ( isset($_REQUEST['p']) ) { switch ($_REQUEST['p'])
{
case 'about': print '4';
break;
case 'blog': print '5';
break;
case 'team': print '1';
break;
case 'products': print '6';
break;
case 'howtobuy': print '3';
break;
case 'spreadtheword': print '2';
break;
case 'join': print '7';
break;
case 'share': print '8';
break;
default: print '1';
break;
}
}
?>.jpg");
}
Report this snippet