Page 1 of 1
Includes & PHP
Posted: Mon Jun 25, 2007 5:39 pm
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.
Re: Includes & PHP
Posted: Mon Jun 25, 2007 7:39 pm
by cyberman
Try this
Code: Select all
global $gCms;
global $config;
include $config['root_path'] . DIRECTORY_SEPARATOR . 'filename.php';
Re: Includes & PHP
Posted: Mon Jun 25, 2007 8:13 pm
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.
Re: Includes & PHP
Posted: Mon Jun 25, 2007 8:39 pm
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';
Re: Includes & PHP
Posted: Tue Jun 26, 2007 1:44 pm
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.
Re: Includes & PHP
Posted: Tue Jun 26, 2007 2:45 pm
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.
Re: Includes & PHP
Posted: Wed Jun 27, 2007 6:06 am
by cyberman
Have you tried to use ful / absolute path for fopen?