Includes & PHP

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm

Includes & PHP

Post by versatility »

I have a PHP application that is currently inside a folder in the site root.

I have tried to call it on a cms page using a variety of methods:

Entering the php in a UDT
Putting an include statement in a UDT (various formats)

No matter what I do, all the file references and variables inside the app break.

I saw a post that referenced this:

Code: Select all

global $gCms;
include $gCms->config['root_path'] . DIRECTORY_SEPARATOR . 'filename.php';
and said to put it in the UDT

and I think it is in the ball park of my problem - but I do not know how to modify it to make it work.  Do I replace root path, directory separator and filename?

Or is there a different approach I should be using?

Thanks in advance.
cyberman

Re: Includes & PHP

Post by cyberman »

Try this

Code: Select all

global $gCms;
global $config;
include $config['root_path'] . DIRECTORY_SEPARATOR . 'filename.php';
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm

Re: Includes & PHP

Post by versatility »

Thanks, Cyberman, I may still be doing something wrong.

I put this in:

global $gCms;
global $config;
include $config['root_path'] . DIRECTORY_SEPARATOR . 'app/search.php';

I still get error messages like this:

Warning: main(include/locale.php): failed to open stream: No such file or directory in /var/www/vhosts/robertspikol.com/httpdocs/idx/include/dbcommon.php on line 24

and that line that file refers to another series of includes like:

include("include/locale.php");
include("include/events.php");
include("include/commonfunctions.php");
include("include/dbconnection.php");

There are about 20 lines of errors referencing files in a similar fashion.
cyberman

Re: Includes & PHP

Post by cyberman »

versatility wrote: Warning: main(include/locale.php): failed to open stream: No such file or directory in /var/www/vhosts/robertspikol.com/httpdocs/idx/include/dbcommon.php on line 24
Is this the correct path to your files?

Have you tried to use

Code: Select all

include $config['root_url'] . DIRECTORY_SEPARATOR . 'app/search.php';
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm

Re: Includes & PHP

Post by versatility »

Cyberman, it's a third party script and it looks like the files really aren't where they say they are - weird.  Thank you for the help, not working but not a CMS problem I do not think.  The app works great outside a CMS page, and it doesn't look like I have the necessary knowledge to figure out why it doesn't work inside.
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm

Re: Includes & PHP

Post by versatility »

I am thoroughly stumped - if you go to this link http://robspikol.theversatilitynetwork.com/idx/property_search.php you can see that this works as expected when not called from within a CMS page.  It is the same file I am trying to call from within CMS.

On the home page, where I am trying to include it, I still get an error http://robspikol.theversatilitynetwork.com/ (Ignore the iframe above it - one other solution I tried and discarded) - the error is

Code: Select all

Warning: fopen(include/errors.xml): failed to open stream: No such file or directory in /var/www/vhosts/robertspikol.com/httpdocs/idx/include/commonfunctions.php on line 662
Cannot open XML data file: include/errors.xml
So it would seem CMS is somehow complicating things, but I do not know precisely how or where.  I'm pretty desperate to get this working, so any and all help is deeply appreciated.
cyberman

Re: Includes & PHP

Post by cyberman »

Have you tried to use ful / absolute path for fopen?
Post Reply

Return to “CMSMS Core”