Page 1 of 1

Embed CMSMS in Another PHP Site

Posted: Wed Jun 25, 2008 11:44 pm
by sjg
I needed to be able to use CMSMS protected content, modules, etc in an established PHP site. I can't migrate the site to CMSMS, but I can make changes on pages.

Here's a simple way to do it.

Install CMSMS in a directory. In this case, I installed it in a directory named "cmsms" within the directory containing the established site.

At the top of the pages that will have embedded CMSMS, put in:

Code: Select all

<?php
@ob_start();
include('cmsms/index.php');
$out0 = ob_get_clean();
$out = ob_get_clean();
$thisFile = str_replace(dirname(__FILE__),'',__FILE__);
$out = str_replace('index.php',$thisFile,$out);
?>
The string replace is so that any modules installed will submit their forms back to the correct file (tested with FormBuilder).

But maybe you want to embed pages other than the default CMSMS page? Simply pass your page=my_page_alias parameter on the URL to the wrapper page, or hard code it like:

Code: Select all

$_GET['page']='my_page_alias';

right before the include.

This all works very nicely. The CMSMS Admin will continue to be usable as normal, for managing modules, etc.

You can prevent direct requests to your CMSMS directory via your web server, if you choose.

Enjoy!
___Samuel___