I am switching to ModX from an old static HTML site and, for the most part, it’s a HUGE improvement. However, I had a little PHP document retrieval system on the old site (basically, a single page called "search.php") and have been unsuccessful in porting this over to work within my new ModX site. The main difference with this search.php page is that the code started with an include statement such as the following:
<? include (’./includes/config.php’)
I would like to deliver this exact same page through ModX but all I get is errors. Not sure what the problem is.
I am using Friendly URL’s and the latest 1.0 ModX.
Thanks
-
☆ A M B ☆
- 2,475 Posts
Where are you putting this bit of PHP? And have you changed hosts? Some hosts don’t allow for the "<?" shorthand -- sometimes they require the full "<?php" style tags.
You should definitely use <?php and try this code:
<?php
require_once(MODX_BASE_PATH . '/includes/config.php');
?>
(assuming that that’s where you put the config file.)
BTW, MODx won’t run any php code unless it is in a snippet or plugin. So you need to create a snippet containing the code above and a new document with just a call to that snippet.
Depending on the code in the file, you may need to change the snippet code to this:
return require_once(MODX_BASE_PATH . '/includes/config.php');
You might want to look at the "Porting your site to MODx" section of the site in my sig.