RantFever 4

I pontificate but not in the pejorative sense of the word.

The Old Archive

Posted 8 April 2013
Written by Abinadi Ayerdis
Category PyroCMS

The older versions of Rant Fever (v. 3, 2, 1, and beta) were a group blog. And as such, there are a good 1,500 posts there. The new PyroCMS install didn't have those old posts, of course. And since Rant Fever was a proprietary content management system, there was no built-in way to automate importing all those posts. I could have figured out a way to bring them into the Pyro blog, but I wanted to keep them separate while still keeping them accessable. After all, that is a lot of wit to just throw away. I thought I could just put the posts in a couple of tables alongside the rest of the Pyro install and access them via a module I could write.

My first PyroCMS module

I had two tables full of information. Well, really I had more, but I consolidated it all into two tables: posts and comments. The comments have a field that point back to the posts table. Databases 101. I threw those up into the PyroCMS database, giving them the site db prefix, and then looked up how to write a module in Pyro.

Writing a module for PyroCMS is a lot like writing any Codeigniter application. It was super easy. At least, it was for this module. It helped that I didn't need an admin area, since I only want to display the old archive on the front end. The first thing to do is to create the folder structure and a details.php file. The file tells Pyro what it needs to know to register or "install" the module. That might include creating and populating tables in a database. Not for me, however. I already had the tables I wanted, and I never want to delete those tables or repopulate them. They are static, as far as I'm concerned. That made the details.php file a simple class with an associate array. Done.

Next up, create a controller with the same name as your module. I also made a model and a couple of views. The views display within the default template of your site, so you don't need to create a whole layout with header, footer, etc. Basically, I query the database for the posts and display what results I get. I tried to use some of the same structure and classes as Pyro's blog page so they look and feel similar. 

I could have written plugins that queried the database. Then I could have created a normal page and used the plugins there. But I felt like the way I did it was easier than having to manage the tags. So now I have tons of content on my site along with lots of previously made comments. I don't have to worry about creating new posts or comments for those tables. I don't have to worry about categories or tags for them either. The only thing I am considering doing with them now is including them in the search. Or creating a search specifically for them. But that is a matter for another post.

Comments

Gravatar

10 April 2013

Parenthetically, even though I have the old archive up, I don't think my old Rant Fever co-bloggers will ever go searching through them. I still want them up, though. Because I like what we wrote, and on the off chance that they come looking, they should be there.

Two other considerations before I'm done with the old archive: 1. It should be searchable. I don't think it should be searchable from the main search form, but perhaps its own search somehow. And 2. any old links will be broken now. I am considering adding some sort of routing from the old url structure to the new one.

Posting comments after three months has been disabled.