Embedding PHP in Pelican-generated Static pagesTue 10 June 2014 by Fred Clift
So, I wanted to make a simple website with pelican. But I had a little legacy php code that I still wanted to function.
It sure would be nice, I thought, if I could take my php app and with only small tweaks make it work as PART of pelican staticly generated page. But pelican doesn't directly parse php. I could just staticaly copy my php pages into my docroot and have some links to them but then I loose the menu, the CSS etc.
Long story short, I made a reStructuredText page in content/pages that has the following:
Sample Php App ############## :date: 2014-05-03 10:20 :url: pages/sample.php :save_as: pages/sample.php .. raw:: html :file: php/sample.php
php/sample.php is relative to the directory that this RST file is in.
The php page can run standalone and produces the output I want, minus the site integration. PHP is not one of the formats that pelican knows how to process so it ignores the php code.
When I generate my html output (e.g. 'make html') pelican generates a page http://mysite/pages/sample-php-app.php which has a big html wrapper around some php code. Works great and it lets me integrate some legacy php tools into an othewise static site.