bbsengine3 handbook: page-tmpl

page.tmpl

in december, 2015 I made some mods to displaypage() that allowed for a 'page.tmpl' (or other template) to be used to display pages instead of calling functions like fetchpageheader, fetchsidebar, fetchpagefooter, etc. this was done for a specific project and I have merged it into bbsengine.

in previous versions of bbsengine, php code needed to be written whenever a static page element needed to be displayed (for example, a sidebar or a topbar).

for a project, there was a need to allow for a 'sticky footer'. the only way to do it before the design change was to modify each php file to include some div tags. while not difficult, it was clear that something had to be done to simplify the process a bit. it should not be required to write php in order to change the overall page layout.

displaypage() was modified to accept an 'options' dictionary with a 'pagecontent' key and an optional 'template' key which defaults to "page.tmpl".

the new displaypage() code allows for a template (by default, "page.tmpl") that assigns all keys in the 'pagedata' dictionary to a template, and calls setBodyContent() once. this allows for flexibility in that if something other than a standard 'body' key needs to be assigned, do so in the php and handle it in the smarty3 template without fuss.

if there is a need for a page different from the site-wide page.tmpl, assign a 'template' key to the 'options' dictionary, set up pagedata as appropriate, and you are done.

the changes are backwards compatible to the original way of building a page so an extensive number of changes to old sites are not required. if 'pagedata' does not exist, the original page instance is used. thank goodness.