Posted By

nijgnet on 02/25/08


Tagged

css wordpress dynamic


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

basicmagic
tmbrenneke
marclarr


Loads a stylesheet with dynamic values dependent on the Page view


 / Published in: PHP
 

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

  1. /*** file: header.php ******************************/
  2.  
  3. <link rel="stylesheet" type="text/css" media="screen" href="<?php
  4.  
  5. //Import stylesheet for the different pages
  6. if ( is_frontpage() || is_page('index') || preg_match( "#/index/#i" , $_SERVER['REQUEST_URI']) ) {
  7. print getdir().'/home.css';
  8. }
  9. else {
  10. echo getdir().'/sub.css.php?p=';
  11. if ( is_home() || is_single() || is_archive() || preg_match("#/blog/#i",$_SERVER['REQUEST_URI']) )
  12. print 'blog';
  13. else {
  14. $post_parent = get_post($post->post_parent);
  15. print $post_parent->post_name;
  16. }
  17. }
  18. ?>" />
  19.  
  20. /*** file: sub.css.php ******************************/
  21.  
  22. <?php header('Content-type: text/css'); ?>
  23.  
  24. div#sidebar_photo {
  25. background-image: url("images/sidebar_photo<?php
  26.  
  27. if ( isset($_REQUEST['p']) ) {
  28. switch ($_REQUEST['p'])
  29. {
  30. case 'about': print '4'; break;
  31. case 'blog': print '5'; break;
  32. case 'team': print '1'; break;
  33. case 'products': print '6'; break;
  34. case 'howtobuy': print '3'; break;
  35. case 'spreadtheword': print '2'; break;
  36. case 'join': print '7'; break;
  37. case 'share': print '8'; break;
  38. default: print '1'; break;
  39. }
  40. }
  41. ?>.jpg");
  42. }

Report this snippet  

You need to login to post a comment.