Blog Pile

Breaking Up The Best of Show

I just got self distracted, not in twittter, but twiddling here with the blog. For quite some time, I have rigged together a ‘Page’ in WordPress that uses a RSS feed with info on all the presentations I’ve done going back to 2003. This was generated by sending the feed to the Feed2JS site to dynamically make the page.

I’m writing up notes here how it was done- the new thang is up at http://cogdogblog.com/best.php

What I did not like was that it grew rather long, so I decided to make it be a PHP script that would dynamically do the right thing per year. The first step was breaking up a long single XML file into smaller files, one per year, e.g. 2003, 2004, … 2007. Just cut n’ paste.

The idea is to have a web form in the page that presents a menu one can choose from- the thing with a WordPress page is I do not know of anyway to send it a PHP variable to represent the value for the year selected from the menu– as WordPress has its own way of shuffling variables around. So I took a backdoor approach, actually copying the code from my Indy Junior setup.


My method is that the new page created (small “p”) is not a WordPress Page (capital “P”), it is its own PHP driven web content. but with some bits of WP knowledge, I tap into WordPress to generate headers and footers. You can do this by (the exact set of divs may depend on your template):

So you set up a connection to WordPress to generate the header, sidebar, and footer, and you are free to do whatever you want in the middle.

So the first thing I need up front is an array for the values for the years I am covering (2003-2007), and some code to set a default value for the year if the script has not been sent one. So the changes up top make it:

Next, I just need to generate a header and a menu for the main part of the page, inside the div:

Below this some text to declare what we are doing, and generate a link to the RSS feed appropriate to the year we are dealing with

And then we just need to use some PHP to push the right value of the year into the Feed2JS code (zowie! PHP inside Javascript):

And that does it! It pretty much looks like it is part of the main blog site, but actually is outside. Should I ever change the template for my header, fooder, etc, these pages all will go with the flow.

Leave a Reply

Your email address will not be published. Required fields are marked *