使用Blogger(FTP,经典)如何添加对于模板而言过于复杂的功能?
时间:2020-03-06 14:33:04 来源:igfitidea点击:
使用经典模板,通过FTP发布到自定义域。
我想添加自定义元素,例如:
- 归档帖子的树状视图(使用CSS / JavaScript扩展)
- 标签云
- 图片幻灯片
解决方案
通过FTP发布后,我使用PHP处理了Blogger博客。任何服务器端语言都可以做到这一点(ASP,ASP.NET,Python,JSP等)。
我写了一个PHP脚本(blogger_functions.php
)来扫描Blogger FTP所在的目录,并生成一个HTML片段来表示存档层次结构($ snippet
)。
我将此PHP添加到了Blogger模板的顶部:
<?php <MainPage> $site_rootpath = "../"; </MainPage> <ArchivePage> $site_rootpath = "../../"; </ArchivePage> <ItemPage> $site_rootpath = "../../../"; </ItemPage> include($site_rootpath."includes/blogger_functions.php"); ?>
这是模板的侧边栏部分:
<?php echo $snippet; ?>
然后,我将Apache配置为通过将Blog的.html文件中的PHP标签处理
这在博客的根目录中的.htaccess文件中:
AddType application/x-httpd-php .html .htm
通过这种方法,我们可以在Blogger博客中充分利用PHP的功能。