I've written a Zend application and also have incorporated Wordpress for blogging. Initially when i first installed Wordpress I designed it to ensure that it used exactly the same header etc because the primary application. I've since remade the primary theme two times and needed to redo the Wordpress theme to complement. It is possible to method for Wordpress to make use of my Zend layout? My first ideas will be to split up my layout into header/footer files and can include them from Wordpress while using full pathways. Even though it works, it's not even close to ideal (I would rather keep your layout file successfully).

For those who have a webpage class the layout/view script uses or similar you could do this something similar to this within the wordpress theme file:

$page = new Page


$content = ''

if (have_posts())



       $content .= doctor_get_clean()




$view = new Zend_View()

$view->page = $page


Wordpress does not allow it to be easy using its functions that output rather than coming back, hence the doctor_start().

I'm not sure if this sounds like the easiest way though, I'd have an interest to ascertain if there's an easy method.

I've separated my layout.phtml file into header and footer partials.

During my Wordpress theme files I'm including my partials.

A far more elegant solution would be to write my very own get_header/footer function which include these partials? I believe this could use the theme's function.php file?

For a lot of websites you may want to install Wordpress for blogging integration. If this involves skinning your blog you're virtually restricted to copying the html out of your Zend_Layout in to the Wordpress header.php and footer.php files. This really is duplication, and when you are making any changes for your layout, you will have to update your blog theme too. Well, there's one other way!

Change Your Zend Application

Create a separate bootstrap apply for your Zend application (for instance by using this informative guide: Access Zend Application Resouces using their company Programs).


// Define road to application directory


     define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'))

// Define application atmosphere


     define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'))

// Ensure library/ is on include_path

set_include_path(implode(PATH_SEPARATOR, array(

        realpath(APPLICATION_PATH . '/../library'),



/** Zend_Application */

require_once 'Zend/Application.php'

// Create application, bootstrap, and run

$application = new Zend_Application(


        APPLICATION_PATH . '/configs/application.ini'



Inside your index.php file, to operate the application:

include('bootstrap.php') //where bootstrap.php may be the file from the new bootstrap file


Wordpress Miracle

Now comes the Wordpress miracle.

Get Zend Layout

Inside your new Wordpress theme folder, produce a file named 'Zend_Layout.php' and copy/paste this code in it:


//load Zend_Layout

$layout = new Zend_Layout()

//add the blog's stylesheet towards the header

$view = $layout->getView()

$view->headLink()->appendStylesheet(get_bloginfo( 'stylesheet_url' ))

// Set a layout script path:

$layout->setLayoutPath(APPLICATION_PATH . "/modules/default/sights/scripts")

$layout = $layout->render()


Alter the header.php file to:



echo substr($layout, , strpos($layout, '<div id="container">'))


    <div id="container">

This can load the $layout variable in the previous script and echo everything as much as your primary container div. Footer

The footer.php is comparable:

    </div><!-- #primary -->



echo substr($layout, strpos($layout, '<div id="footer">'))