Yes, it’s about time to try something a little …. different with the site. Everyone’s Blogging now, and let it not be said that I do not bend whichever way the wind blows! So I’ve spent some time and made a blog to seamlessly fit into the existing site. No content will be lost, and new content will be added … only we have a blog now too!
Why blogger? I could probably program a blog myself, but most everyone I know of uses Blogger. I’ve even commented on Blogger-run blogs. So Blogger it is.It’s always better to use an existing tool familiar to most than a new tool, I always say.
That said, this post will deal with using PHP in order to mesh Blogger into your site as well as some of the problems I ran into trying to get Blogger onto the site in the first place. Forgive me if I get a bit technical.
- Read this. gives a good starting point, but there was no part two (at least that I could find). My site uses PHP, so I had to wing this part on my own.
- By the way, that last step, publishing via FTP, does not come on at once. You have to save your domain name and then come back. Nowhere I have seen has been clear on this point. Hell, my memory is already fuzzy.
I have to admit, I don’t like the bump that Blogger throws you when you get started. But don’t let it deter you.
The way I have MM3 set up is that the headers and footers are placed dynamically via PHP. The challenge is that the files aren’t all put in one folder, or even the same level. Some are in root level, others are two folders into the site. So just putting “../” won’t work. And neither will putting an absolute link, not for your includes.
To add to the challenge further is that I don’t want the blog to interfere with the way my main page is set up (namely the sidebar with a ton of links; it has no place on my main page), but I *do* want it on every other blog-related page on the site.
Both problems have the same solution. You need php to check what page you’re and do something depending.
- First, you want to go into Blogger and into “Settings” > “Archiving” and change the “Archive Filename” to “archive.php”. This will make all the pages .php pages.
- <?php
$thisPage = $_SERVER[SCRIPT_NAME];
if ($thispage !=”/index.php”)
{
<insert code>
};
?>
- This is the code you need and, basically, the linchpin of making your own Blogger template using PHP. I’ll attempt to explain.
- $this page – This is a variable that stores you page’s name. In this case we’re looking for “index”.
- The next line of code tells the page to do something if the page is not the index page.
- After that it’s a matter of putting in what code we want. FYI: “==” is what you want to use to check if something is the variable you’re looking for.
- This is what goes in the “<insert code>” area. Or at least what i put.
echo “<style type=’text/css’>
#sidebar {
display: block;
}
#newsBlog{
float:right;
width:570px;
}
#sidebar{
width:175px;
float:left;
position:relative;
margin-left:0px;
margin-right:0px;
font-size: smaller;
}
#sidebar h2{
text-align:left;
}
#powered-by, #blogfeeds{
text-align:left;
}
</style>
<a id=’#Top’ name=’#Top’></a>”;
echo “<h1>Previous Posts</h1>”;
Okay, scary big code up there. Don’t let yourself be intimidated! All this is is the styling format for the pages that aren’t the index page. Since it’s placed below the regular css file I use for the rest of the site, it overrides it.
Using the method above you can make the blogger pages look differently than your index page. Which is the key to integrating it into your site. This includes the “Back to top” links and “View previous Posts” links I put in my own layout. Blogger only lets you have one layout, so it’s best to think things through.
- if (file_exists(“../layout/top.php”)) {
include “../layout/top.php”;
} else if (file_exists(“../../layout/top.php”)){
include “../../layout/top.php”;
};
So, there you have it. That’s how you integrate Blogger into your site structure using php. Or at least how I did it.