Liam
Liam

Reputation: 20980

With Blogger (FTP, Classic) how do you add features that are too complex for the template?

Using classic templates, publishing via FTP to a custom domain.

I want to add custom elements such as:

Upvotes: 1

Views: 569

Answers (1)

Liam
Liam

Reputation: 20980

I used PHP to process a Blogger blog after it is published via FTP. Any server side language can do this (ASP, ASP.NET, Python, JSP, ...).

I wrote a PHP script (blogger_functions.php) to scan the directory that Blogger FTP's to and generate a snippet of HTML to represent the archive hierarchy ($snippet).

I added this PHP to the top of my Blogger template:

<?php 

<MainPage>
$site_rootpath = "../";
</MainPage>

<ArchivePage>
$site_rootpath = "../../";
</ArchivePage>

<ItemPage>
$site_rootpath = "../../../";
</ItemPage>

include($site_rootpath."includes/blogger_functions.php");

?>

And this to the sidebar part of the template:

<?php
echo $snippet;
?>

Then I configured Apache to process the PHP tags in the blog's .html files by putting this in a .htaccess file in the root directory of the blog:

AddType application/x-httpd-php .html .htm

With this approach you can use the full power of PHP with a Blogger blog.

Upvotes: 2

Related Questions