The redesign of Pixelog.org
One of the things that drove me to WordPress was the fact that it was PHP based. It leaves the doors wide open for you to do practically any kind of hack you could possibly think of.
I recently reworked Pixelog.org for Christine. The original was a table based design, powered by MT. Now it’s all CSS based, valid XHTML 1.0 Strict, and powered by WordPress!
However, to get everything to work just so I had to pull a few tricks….
1) Browser resizing
Christine couldn’t decide between a horizontal layout which she preferred, or a vertical one (which would be more “smaller browser” friendly. So, we did both! I used the getBrowserWidth() javascript that The Man in Blue used for this sample for resolution based layouts, and some of the javascript mentioned here. The end result, while not as fancy as The Man in Blue’s - it does the trick. Each time the browser is resized, the screen is refreshed, and the stylesheet appropriate for your browser width is loaded.
2) Extract just what you need
Pixelog.org is already a few years old. Back then, we hardcoded awful things like borders, styles inside the img tag itself. I REALLY wanted the site to validate, but there was so much junk in the posts and img tags, and with 230+ posts, there was no way we were going to be able to edit everything and clean it up. Since the “main” part of the post was being handled one way, and the “more” part of the post completely seperate, I was going to have to access the “raw” data anyway.
So, to get JUST the “main” part of the post I did this:
$content = explode(’<!–more–>’, $pages[$page-1]);
then to extract just the url to the image, Matt gave me this little code snippet:
$jpg = preg_replace(’/.*(http:.*?.jpg).*/i’, ‘$1′, $content[0]);
now I can reconstruct the URL and make it a clean img tag:
echo ‘<img src=”‘.trim($jpg).’” alt=”‘.$post->post_title.’” />’;
Then, where I wanted the “more” to display, I did this:
$content = explode(’<!–more–>’, $pages[$page-1]);
echo apply_filters(’the_content’, $content[1]);
(note: By doing things this way - you may bypass some of the other filters wordpress does! So, while this worked for this particular situation, as they say “your mileage may vary!”
3) Category view on it’s own page
I wanted to keep the cateogry page on a completely different page as the rest of the site. We’re not using the “nicer” permalinks, so I set up a redirect based on the query string in the url. This is on the index page:
<?php
if (isset($_GET['cat'])) {
$url = “/catview.php”;
if (isset($_SERVER['QUERY_STRING'])) {
$url .= “?”.$_SERVER['QUERY_STRING'];
}
header(”Location: “. $url);
exit;
}
?>
“catview.php” is the category page. On that page I have this code at the top:
<?php
if (!isset($_GET['cat'])) {
$url = “/index.php”;
if (isset($_SERVER['QUERY_STRING'])) {
$url .= “?”.$_SERVER['QUERY_STRING'];
}
header(”Location: “. $url);
exit;
}
?>
4) Pixelog on BigPinkCookie
The last trick was getting the thumbnails from the most recent pixelog posts to show up on Christine’s main blog BigPinkCookie. The nice thing is that since they’re both now powered by wordpress and are in the same database (just with different table prefixes), we already have a plug into the database we need. Again, it’s a matter of getting to the raw data. I get the excerpts (which have the thumbnails in them) like this:
$pixelog = $wpdb->get_results(”SELECT ID, post_excerpt FROM PREFIXHERE_posts WHERE post_status = ‘publish’ order by post_date desc limit 10″);
Then I go through each result like this:
foreach ($pixelog as $v) {
echo “<li class=’pixelogborder’>
<a href=’http://www.pixelog.org/index.php?p=”.$v->ID.”‘>” .
$v->post_excerpt .
“</a>
</li>”;
}
Update: I should probably add, the way Christine is entering her posts to get this to work; Thumbnails go in the excerpt field. The main photo goes as the “main” part of the post. And her “notes” go in the “more” part of the post.
October 21st, 2004 at 11:43 pm
Now introducing the NEW and IMPROVED Pixelog!!!
Mad props to Jennifer for many hours of hard work - she has truly made my dream a reality. I’ll share more of what went on behind the scenes with the site tomorrow, but for now I just had to share th…
October 22nd, 2004 at 1:52 am
Just wanted to say that it really looks brilliant. Very clever way of including both horizontal and vertical types of websites into one.
October 22nd, 2004 at 6:42 pm
WOW!
Is there anyway lame designers like your’s truly can get the modded WP?
It’s truly amazing. Must be about the best photolog I’ve seen, designed around WP!
October 22nd, 2004 at 7:53 pm
Heads up!
the latest Firefox nightly has disabled the reload on resize functionality.
see here: Burning Edge And here: Bugzilla
Neat Design Regardless.. Kudos.
October 22nd, 2004 at 9:41 pm
thanks for making me drool all over my keyboard. I have been wanting a photoblog for a few months now and I cant find anything that I dont have to code my self. anyone got any suggestions?
October 22nd, 2004 at 10:47 pm
Filed under: Beautiful Blogs — Carthik @ 6:47 pm
ScriptyGoddess writes about her red [...]
October 27th, 2004 at 2:38 pm
Wow, that’s GORGEOUS…. how could someone do something similar on one’s own blog? I LOVE that you did it up seperate….
October 29th, 2004 at 5:40 pm
October 29th, 2004 at 10:34 pm
please please! share the code!
October 29th, 2004 at 10:38 pm
Duncan - that’s what this post was all about
All the major hacks I did to get the site to work - are right there. Was there something else I left out?
October 30th, 2004 at 11:53 pm
really? thats it? (im not a programmer at all?) i have WP setup, pretty outta the box, but really like the photo blog setup you have going. is it these couple snips and a layout that make it work like it does? it just look so different (design aside) in terms of layout, nav etc.
November 13th, 2004 at 2:02 pm
I’ve been fascinated with pixelog.org - such a beautiful, elegant, simple and generally delightful site. I found this link on scriptygoddess . One of the things that drove me to WordPress was the fact that it was PHP based. It…
December 4th, 2004 at 11:29 am
Jennifer — this is a great tutorial. Are you playing with 1.3 yet? I think this can be made even easier.
December 4th, 2004 at 10:43 pm
I have played around with 1.3 a bit. It looks very cool, and I’m anxiously anticipating the final release. Because there are a several “customizations” I do to my blogs, upgrading is a bit of a hassle. (Long term plan is to reduce the number of customizations - well at least the ones that make upgrading a hassle - and I think with 1.3 that I will get closer to that) So rather than keeping up to date with the latest build, I’m holding off making the big jump for when the final version is out. This way I only have to make those customizations once…