Messing with PHP and CSS

I know I’m not a full time coder (and all of you full time web developers will make fun of me), but I’m glad I got a few things working today. After switching to WordPress (and leaving a lot of Mambo CMS content behind), I decided I wanted to try modifying themes. I installed 3k2redux-klein and added random header images, and I put in my flickr badge.

For the random image code, I hope this is a decent way to do it. I made a custom stylesheet with a “.css.php” extension — so basically, it’s a CSS with a little PHP code in it. In the theme’s images directory, I have a bunch of files that start with “head_”. So, there is a regex that finds all the files with that prefix, and loads it into an array:

if (preg_match(’|^head.+?\.jpg$|’, $file)) {
$headimg_files[] = $file;

Then I count the size of the array, and randomly pick the index of one of the images in the array.

It still takes me a little while to look up the right function calls, but I’m glad to get the practice. :)


0 Responses to “Messing with PHP and CSS”

  1. No Comments

Leave a Reply





My Flicks

www.flickr.com
This is a Flickr badge showing public photos from Rich Moffitt. Make your own badge here.

Subscribe

Subscribe to my RSS Feeds