Placing my LOAD RECORDS in a include file
7 posts by 3 authors in: Forums > CMS Builder
Last Post: December 22, 2014 (RSS)
By drewh01 - December 15, 2014
Is this possible? If so, how do I do this? I would like to place all of my load records in of location so I do not need to place them on every page. thx/
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
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/
By drewh01 - December 16, 2014
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.
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/
By drewh01 - December 22, 2014
I think we have a winner! I guess sometimes it's the simplest fix that does it.
thanks!