Integrating 3rd Party CMS Content Within Magento

Last modified by RoyRubin on Fri, June 25, 2010 09:57
Source|Old Revisions  

Integrating 3rd party CMS content into Magento has been a popular request by the Community. Outlined below is a technique using Expression Engine with the idea of managing content pages with EE, and displaying the content within Magento, using Magento’s 404 event handler. We will fetch this content using Varien_Http_Client.

Please note that Expression Engine is used for demonstration purposes only and other CMS platforms (Wordpress, Modx, Joomla, Drupal) can be used if desired. magento-ee-large.jpg

Getting Started

For this example, we’ll assume Expresion Engine is installed inside the Magento directory in a folder called ‘ee’, so our store’s URL will be and our EE’s URL will be

Note: Both Magento and EE must be installed with the Apache URL rewrite feature.

The .htaccess file for EE:

  1. RewriteEngine on
  3. RewriteCond %{REQUEST_FILENAME} !-f
  4. RewriteCond %{REQUEST_FILENAME} !-d
  5. RewriteCond %{REQUEST_FILENAME} !-l
  7. RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

The home page of your installed EE must be the same as your Magento store home page (

Create a Local Code Pool Module

We will create a module in the local code pool as follows:

- create a new directory called “Project” under “app/code/local/Mage”

- create a new directory called “Block” under “Project”

- create a new file called Noroute.php under “Block” and copy the following code into the script.

  1. class Mage_Project_Block_Noroute extends Mage_Core_Block_Abstract
  2. {
  3.     protected function _toHtml()
  4.     {
  5.       /**
  6.        * This logic should be in the controller, model, but let's make
  7.        * this quickly without lots of files :)
  8.        */
  10.         $uri = Mage::getBaseUrl() . 'ee' . $this->getRequest()->getRequestString();
  11.         $post = $this->getRequest()->getPost();
  12.         $method = ( count($post) == 0 ) ? 'GET' : 'POST';
  14.       /**
  15.        * You can add additional
  16.        * headers like cookies, redirects and so on
  17.        * if you need it here.
  18.        */
  20.         $client = new Varien_Http_Client($uri);
  21.         $client->setParameterPost($post);
  22.         $response = $client->request($method);
  24.         $body = $response->getRawBody();
  25.         return $body;
  26.     }
  27. }

To enable the Project module from local pool, create a file called “Magento_Project.xml” under “app/etc/modules” and copy the following code:

  1. <?xml version="1.0"?>
  2. <config>
  3.     <modules>
  4.         <Mage_Project>
  5.             <active>true</active>
  6.             <codePool>local</codePool>
  7.         </Mage_Project>
  8.     </modules>
  9. </config>

Create a Layout

Now we need to add this block to the layout. Let’s edit the app/design/frontend/YOUR_DESIGN_PACKAGE/default/layout/cms.xml and modify ‘cms_index_defaultnoroute’ section:

  1. <cms_index_defaultnoroute>
  2.         <remove name="left"/>
  4.         <reference name="root">
  5.             <action method="setTemplate"><template>page/1column.phtml</template></action>
  6.         </reference>
  7.         <reference name="content">
  8.             <block type="project/noroute" name="no_route" />
  9.         </reference>
  10.     </cms_index_defaultnoroute>

Next, we’ll disable the 404 page (identifier: ‘no-route’) in the Magento administration (CMS→Manage Pages).

Finally, refresh Magento’s Cache and edit the templates within EE removing all headers, footers. Visiting pages like will now include the content from with Magento’s header, footer and other components.

Extending the Technique

In order not to redirect all invalid requests to EE, a regex expression can be added to limit the requests that are redirected to EE and such requests will processed by the Magento’s noroute handler.