Using Blogger with ASP, PHP and Other Scripting Languages

Did you know that you can use Blogger to build sites with scripting languages like ASP and PHP? You can and it isn't really hard to do either.
First off, I've only found this works if you are using the FTP option to publish a site to your own web hosting service. Last time I tried, BlogSpot (Google's free hosting for Blogger blogs) didn't support any scripting languages that I could discover. If anyone finds out differently, please tell me. Also, the web service you are publishing your blog to has to have support for the scripting language.
That out of the way, there are a few setting in your Blogger control panel you need to tweak to get this to work.
First, you need to go under "Settings" and then "Publishing" and then look down that page for an entry titled "Blog Filename". By default, this will be "index.html". Change this to the appropriate entry for the scripting language you are using - default.asp (ASP), index.php (PHP), etc.
This will make sure the main page is generated with a suffix appropriate to the scripting language you are using. Now we need to get all of the other pages to do the same thing.
It isn't obvious that this will actually be controlled by the setting under "Settings" and "Archiving". Look down this page to the entry that says "Archive Filename" and change that to have an appropriate suffix as well. By default, it will say "archive.html" but you should change it to have an appropriate suffix - achive.asp (ASP), archive.php (PHP), etc.
I've used this with ASP and PHP but getting it to work with ASP.Net (e.g. "default.aspx") is a bit tricky.
Changing the archive setting affects the rest of the pages built by blogger. If you have Blogger configured for monthly archiving - then each of those monthly archive pages will follow the template set by the Archive Filename. If you have Enable Post Pages set to "Yes" those individual post pages (where a permalink points to) will also follow that pattern.
That is about it. Changing those two settings will get Blogger to generate filenames with the write suffix to be processed as script files. This means you can now embed script code into your blog posts.
There is one other setting you don't have to use but probably will want to. Under "Settings" and "Formatting" you should probably set "Convert Line Breaks" to "No". If set to "Yes" how Blogger re-formats your posts may interfere with the code sections being properly interpreted by the script processor in your hosting service.
Changing this last setting certainly makes editing the code easier to read. Otherwise, Blogger can re-format you posts to strip out the white space.
The code

echo 'Hello World!';
ends up as ...

<?php echo 'Hello World!'; ?>
The HTML and code may still work and for small snippets isn't a problem but for larger blocks of code quickly can be near impossible to read.

No comments: