Placing my LOAD RECORDS in a include file

7 posts by 3 authors in: Forums > CMS Builder
Last Post: December 22, 2014   (RSS)

By claire - December 16, 2014 - edited: December 16, 2014

Hi there

The best thing to do is just copy the code block into a separate file and then use an include statement on each page to load them, like so:

include('/assets/includes/loadRecords.php');

Make sure you get the path right, and it'll load that block of code anywhere you put this line. Do note, however, that you might get errors if you load it out of order, so make sure you put this line where the code block would normally be on that page.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

I tried that before, but was never able to get the page to load.  I all of the load records code into the loadrecords.php and always get a blank page.

-----------

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php include('/includes/loadrecords.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

By claire - December 16, 2014

I'd say you've got some getRecords functions conflicting with each other then. The 'allowSearch' parameter is especially nasty for this. getRecords responds to stuff in the $_REQUEST array if you don't set 'allowSearch' to false.

That said, if you need a particular query to respond to the $_REQUEST array, you can certainly leave 'allowSearch' set to true. But it's likely it'll still cause weird behaviour when stuff gets into $_REQUEST that you didn't expect for that page.

Best thing to do is put the stuff you know for a fact can be set to allowSearch => false into the loadRecords.php file, and put everything else in the viewer files.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By rconring - December 22, 2014 - edited: December 22, 2014

Try removing the leading slash so it reads:

<?php include('includes/loadrecords.php'); ?>

I use includes extensively and they only work without the leading slash in the path.

See this http://stackoverflow.com/questions/5366225/php-include-when-a-root-forward-slash-precedes-the-included-path-like-folde

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By claire - December 22, 2014

Thanks Ron, I totally missed that. Go ahead and take out the leading slash before you try anything else.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

I think we have a winner!  I guess sometimes it's the simplest fix that does it.

thanks!