Saturday, February 5, 2011

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:

  • a tree view for archived posts (expanding using CSS/JavaScript)
  • a tag cloud
  • a slideshow of images
  • I can't tell you the answer but you may be wise to research your question here.

    Liam : Thanks, but there was nothing relevant there.
  • 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.

    From Liam
  • So, do I add this as it is, or do I have to change anything? Where, specifically, do I add the code?

    Explain it to me like I'm an idiot. Thanks!

0 comments:

Post a Comment