Embed CMSMS in Another PHP Site

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm

Embed CMSMS in Another PHP Site

Post 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___
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
Post Reply

Return to “Tips and Tricks”