Jul 29 2009

Custom PHP Blogger Support Files

Now that you have your blogger set up to use a PHP , it’s time to make your maintenance easier.

The first thing you must understand is that blogger will publish your blog to many different directories. This is not a problem, however you will need to make an adjustment to any internal link. For example if you want a link or button to the home page of your main site your link would typically look like this href=index.php If this link appears in the directory /archive/somedate/yourblog.php then the browser will look for the index.php page in the /archive/somedate/ which does not exist. So all internal links for your navigation should be the full URL. The link to the main site home page would be href=http://www.yourSite/index.php This also applies to images, css and any other file you might want to call from your blogger template.

The Support Files
Typically I like to set up a support directory for the blog. This directory will hold any support files that I may need to call from the template. A support file can a file that has variables, functions or other information you may need. The reason you will want a support directory is to keep all your files organized in one location (this will make the files easy to find) . This location may look like this /home/yourUserName/bloggerSupport/ and in that directory you may have the header, footer and other support files. For example your support directory may look like this:

-rw-r–r– 1 evantage evantage 5141 Aug 4 13:01 support.php
-rw-r–r– 1 evantage evantage 10389 Aug 8 13:11 functions.php
-rw-r–r– 1 evantage evantage 5430 Aug 5 12:06 favicon.ico
-rw-r–r– 1 evantage evantage 1155 Aug 7 15:11 footer.php

In this directory there is also the favicon.ico this will allow you to use your favicon for your blog, instead of the standard blogger favicon.

If you have support files that have things like passwords or other important data that you want to make sure there is never web access to you can move the support directory to your home directory and that will be out of the reach of the web server so the source code can not be seen from the web.

Calling the support files from the blogger template.
For this example the code to call the function.php file would look like this.


Since the template is published in php your web server will always know where the functions file is located from any directory.

By having you support files in one central location you can reduce your maintenance and debugging time. And the last thing anyone wants to do is debug your code.

WordPress Themes