Page 1 of 1

Integrating custom PHP framework

Posted: Wed Jul 25, 2007 11:08 pm
by Jimbobway
Hey guys, any help you could give with this would rock.

Let me explain the situation properly:
I have a large ammount of experience with PHP and MySql, and recently my employeer has had me use this CMS.  This is my first time using a CMS.  Anyway, I had no problem setting up the first project on it, and have really enjoyed using it. 

I have been using a framework that I created for 2 years now. The framework allows for very easy integration with a database, and does alot of work for me.  I have never had to integrate it with a CMS. 

Yesterday I began to integrate it with the CMS.

I put all of my PHP5 classes into a new “User Defined Tag”.  (*hereafter UDT)

For each form that i have created i have also created a new UDT.  Included in this UDT is all neccesary frontend code to bring the system to life.

Ok, so here are the issues that have arrizen..

1)I had an error handler PHP function.  I tried invoking this, and I got the following error:
Warning: set_error_handler() expects the argument (handleErrors) to be a valid callback in /home/gotbusin/public_html/honeypixel/lib/content.functions.php(669) : eval()'d code on line 1751
My instinct is that in the CMS PHP code there is something that uses this function.. and there is some conflict?  I know 100% that the identicle library code does not produce this error in a parent directory that is seperate from the CMS.
2)When I attempt to call a PHP function called saveRecord (input from a new form)... it coughs out with a 500 saying
500 Server Error
A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.

Can anybody help with this?
I have a few questions also:  Is there a databasing object that can be added onto CMS?  What about form generation? 

Any ideas would rock.
Thanks for reading!
Even more thanks for your thoughts!

Re: Integrating custom PHP framework

Posted: Thu Jul 26, 2007 2:30 pm
by calguy1000
Invoking your own classes, etc.  I would simply
a) modify config.php  and set 'use_smarty_php_tags' to true.
b) In your page template put the necessary includes, like this:  {php}include('filename.php'){/php}

A simple grep for set_error_handler() found calls to this in Smarty, adodb_lite, the geshi plugin, and in xajax.  Also in the ErrorEmailer module but not in the cms core.  Undoubtedly the problem you had was probably an order of execution thing.

Next.... Database access is accomplished using adodb_lite in CMSMS.  You can get a handle to the existing database connection with this code:

Code: Select all

global $gCms;
$db =& $gCms->GetDb();
However, if you need to connect to a different database you'll want to create a new adodb object.

Next, if you want to create forms, etc.  then the recommended method for this is to use the module api and create a new module. It is possible to create your forms in straight html and handle them with a UDT. but if you are thinking of doing something more complex than a module is the proper way to go.

You'll find the module API in lib/classes/class.module.inc.php and to get started with a module you can look at the Skeleton module.

Re: Integrating custom PHP framework

Posted: Thu Jul 26, 2007 8:28 pm
by Jimbobway
Thank you so much.

Your making alot of sense.

There is some code to write!