I love PHP. My server has generously offered to execute any PHP files I put on it (and that’s the good kind of execution, mind you). Not sure what I mean? If you have a MovableType site, you can probably use PHP. Here’s a great trick to make it easier to update your bookroll, links, common header, etc.
You can use MT’s multiple blog feature to create pages that have content that is pulled into other pages. For example, I’m no longer using Blogrolling.com for my blogroll; it’s stored in a file called blogroll.php (my sub-blog for such things is called cms, for content management system).
Why in the world, you ask, would I want to add this level of complexity to my website? Well, one reason is that it’s a pain to edit an enormous template in MT and try to find the one line of code you want to manipulate. So here’s what I do: Create the file as an MT entry and use PHP to include it in all the pages I want it to show up in. Here are step by step instructions:
1. Create a new blog. I’ll call it “cms” for “content management system.”
2. In Core Configuration, set the various path settings to (whatever).com/cms or public_html/cms (depending on your server configuration)
3. In Preferences (under Weblog Config), under “Default Text Formatting for new entries”, select None. This is important - if you set it to convert line breaks, you’ll have tons of extra
tags.
4. Under “File extension for archive files:” enter php (no period)
5. Leave all the rest of the boxes unchecked. You won’t need any of them.
6. Under “Archiving”, delete/uncheck all but the Individual archive. In the Archive File Template box, enter <$MTEntryTitle$>.php - this will save your entries in an easy-to-remember format. They must be in PHP for the server to pull them dynamically (or rather, so they can pull other files dynamically).
7. Delete all the templates except Main Index and Individual Archive. You won’t need the rest.
8. In the Main Index template (which you probably will never need), enter the following (changing the obvious parts to reflect your domain):
4. Make sure your main blog outputs PHP files, not HTML. There are two places to check: In each of your templates, make sure the output file ends in PHP; and in the “Preferences” section of Weblog Config, there’s a box to type the extension you want your pages to have. Make sure this box says PHP.
5. Use your FTP app to delete any old HTML files that have the same name as existing files if you’re just now switching to PHP, because, when you’re server is given the choice between index.html (the old file) and index.php (the new file), you probably won’t get the right one displayed.
6. Republish your blog. Viola! Oh, wait, something probably went wrong. Troubleshoot, and eventually you’ll have a voila! moment.
Enjoy. Email me if you want help.
By the way, in case you’re wondering how I made this entry display all those < and >’s instead of trying to render them as HTML - I just copied & pasted the text of this entry into the comment box, selected all, and hit the “decode” button, then recopied it into the blog entry. Cool, huh?
Now comes the part where this makes your life easier. Whenever you want to edit your blogroll or other elements you include this way, simply go to the cms blog and select “edit entries” (this is even easier if you use W.Bloggar - just select CMS in the drop-down blog selection box). Edit the one you want and hit save. That’s it - blogroll updated with no republishing. Since this file is called in freshly every time a page that uses it is loaded, there’s no need to update any other pages.


You have discovered the power of web programming with one very powerful but simle function…the include! It gets even more fun when you develop your own components. With the way you are going it looks like you might start making your own stuff.
I’d like to eventually, though it seems ASP.net is more promising than PHP for the future of web programming. My friend Aaron Ogle, who posts occasionally to RC, is a web developer. How did you get started - did you major in comp sci in college?
I’m a self taught developer. I started making websites in 96 and just graduated up. I’m fluent in ColdFusion and ASP and I’ve done a lot of work in dot.net. PHP, Java and .net are the future. .net is a pain to work with on simple projects like weblogs but it is great for complex tasks. Linux is here to stay and PHP is the language of choice on that platform.
I still use ColdFusion because it is Java and it offers the quickest development time. My time is worth more than the $1000 dollars I need to upgrade the software every couple of years. With .net you end up paying that much just for their best development environment - Visual Studio.
What would you recommend to learn about programming in general? A friend told me that once you understand the fundamentals, you can learn any language fairly quickly. What’s a good way to learn the fundamentals - data structures, common functions, etc?
Justin-
I would find a good tutorial/reference online. Here are the two I use most frequently:
W3Schools: This is a site with good high-level tutorials and LOTS of examples (which I find most helpful).
DevGuru: This is more of a reference site which I use for the specifics of ASP, VBScript, and JavaScript.
I haven’t done much PHP and for my Java apps I use a big, fat JSP book plus the Java APIs.