Using Figaro Templates
In order to use Figaro's page rendering engine you must create three files:
- A Root level page - naming convention = filename.php (this file contains all of your dynamic code)
- A Template file - naming convention = _template.htm (this file contains persistent elements - header, footer, html start and stop, etc.)
- A Content file - naming convention = filename.content.php (this file contains all of the html specific to that page and any pointers that need to recieve dynamic info)
Setting up the Root level page
- Create a new page in your root directory called "hello.php"
- Open the file and add the following code: $Page = new Page('figaro/pages/_template.htm'); //this tells Figaro what template file to use for this page.
- Add: $Page->defineElement($thisPage, 'figaro/pages/hello.content.htm'); //this tells figaro where the main content of the page is coming from. $thisPage is just a placeholder - it can be any name.
- Add: $hello = 'hello'; //this sets the variable $hello to the string hello.
- Add: $Page->$thisPage->addContent('RIGHTCONTENT', $hello); //this sends the variable hello to the RIGHTCONTENT pointer in your content file.
- Add: $Page->render(); //this invokes Figaro's page renderer.
Setting up the Template file
- Create a file called "_template.htm"
- Insert the standard Doctype and basic html shell stuff in this page
- Somewhere inbetween your body tags insert a place holder (this will be replaced by the Content file you're about to setup)
- This is the place to put any persitent content (navigation, copyright verbage, contentWrapper div)
Setting up the Content file
- Create a file called "hello.content.htm"
- Put the placeholder anywhere in the page. Pointers like this recieve dynamic content from your Root level page.
- Insert anything that you want to be included in this specific page.