Now Some PHP

My buttons were in a Movable Type template module, which was great because it meant that I didn’t need to change every page when the buttons changed.

I did this by creating a new template module (scroll all the way to the bottom of your MT “templates” page) called, appropriately enough, buttons. Then I just added a bit of code to each of the other templates where I wanted to see the buttons in question.

<$MTInclude module=”Buttons”$>

Pretty easy. However, it also meant that I had to recompile every page attached whenever I changed the buttons – for instance, for a new version number or adding a new feed to the list. When I had a couple of entries, it was nothing – but then that time started adding up.

While I was reading mezzoblue one day, I stumbled across a comment that talked about making use of PHP includes without changing your file extensions. Nice! Today I finally got around to investigating further.

It turns out that my provider (now defunct) offers a user-level MIME Type configurator right there in cPanel. So I enter the appropriate information:

application/x-httpd-php with an extension of html

And… nothing. Well, duh – I haven’t actually done anything yet. But at least it didn’t break anything that was already existing, and that’s important.

So I took my existing template module and copied the contents to a new index template that creates a file called “buttons.html”. Then I replaced the prior MT include with a slightly different one:

<?php include ‘<$MTBlogSitePath$>buttons.html’; ?>

After I rebuilt both files, everything still seemed to look okay, so I changed a value in my new buttons index template, rebuilt that template only, refreshed my blog and voilá – the change was there! I only had to rebuild the single template. Since it seemed to work, I spread the love and put the new PHP include in every other template that had the MT include for the buttons, rebuilt everything, and now I can change buttons without rebuilding the whole site!


Posted

in