-
Notifications
You must be signed in to change notification settings - Fork 1
Template Development
Brian McCoy edited this page Feb 23, 2018
·
1 revision
- By default the header, footer and homepage (front-page.php) are set up for you.
- Every template, post type, etc. should be set up with a PHP file and a Twig file. For example if you have
template-about.phpyou would haveviews/template-about.twig - The PHP file should have a class that extends the Core_Template class. Example:
class Template_About extends Core_Template. Whatever the class name is will be what it tries to load from the views directory. In this example it'd look fortemplate-about.twig. You can overwrite this by defining atemplate_filemethod in your class. Seeheader.phpfor an example. - Any methods defined in your class will be returned to the Twig template as data. For instance if you have a method
herothat returns an array you could access it in your Twig file like{{hero.heading}}if you have a key in your array called heading. I recommend having a method for each section of the template returning relevant data for that section. - The
Core_Templateclass also supplies your Twig template with some commonly accessed data:{{constants.blogURL}},{{constants.templateURL}},{{constants.templateDir}},{{constants.mediaURL}}