Return to Snippet

Revision: 5297
at February 25, 2008 14:45 by nijgnet


Initial Code
/*** 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']) )
        print 'blog';
    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");
}

Initial URL

                                

Initial Description
Sets the sidebar photo appropriate for a section of the site by determining the parent Page of the subpage.

Initial Title
Loads a stylesheet with dynamic values dependent on the Page view

Initial Tags
css, wordpress

Initial Language
PHP