Vulnero

Seamless WordPress and Zend Framework Integration

WordPress Templates

Most WordPress themes include a number of templates as php files in your theme's root directory. These files could best be compared to Zend_Layout scripts as they wrap your content based on its context. For example, the TwentyEleven theme (wp-content/themes/twentyeleven) has a special template for displaying pages named page.php.

Vulnero Routes

If you add a route to application/config/routes.ini and go to that route in your browser, Vulnero will wrap it in your WordPress layout with your header, menus, widgets and so on taken directly from your theme. To do this, it needs to use a template. All Vulnero routes are rendered as pages and by default, most themes include a page.php template. If no page.php template exists, it will probably default to the main template index.php; but, this can very by theme.

You may wish to use a different template to wrap your routes. The easiest way to do this is to create a custom template file named page.php and put it in your plugin's root directory (e.g.: wp-content/plugins/vulnero/page.php). This file is a regular WordPress template and supports all the WordPress global functions any other template might use such as the_content or get_sidebar to render WordPress content.

If you would prefer to use a different template from your theme or want to assign your page template based on some arbitrary logic, the following can be added to your bootstrap class at application/Bootstrap.php:

public function onPageTemplate()
{
    $wordPress = $this->bootstrap('wordPress')
                      ->getResource('wordPress');
    // The custom-template.php file should exist in either your theme or plugin root directory
    return $wordPress->locateTemplate('custom-template.php');
}