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

StackOverflow https://stackoverflow.com/questions/116088

  •  02-07-2019
  •  | 
  •  

Question

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

I want to add custom elements such as:

  • a tree view for archived posts (expanding using CSS/JavaScript)
  • a tag cloud
  • a slideshow of images
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top