Multiple records from different editors on same page
9 posts by 3 authors in: Forums > CMS Builder
Last Post: April 5, 2011 (RSS)
By blind2uriz - March 31, 2011
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/content/s/t/u/stud74/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load main
list($mainRecords, $mainMetaData) = getRecords(array(
'tableName' => 'main',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$mainRecord = @$mainRecords[0]; // get first record
// load news
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'perPage' => '1',
));
// show error message if no matching record is found
if (!$mainRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
?>
and what I have in the body is...
<p><?php echo $mainRecord['content'] ?></p>
(for the main content)
and...
<p><?php echo $newsRecord['title'] ?></p>
<p><?php echo $newsRecord['summary'] ?></p>
<p><a href="<?php echo $newsRecords['_link'] ?>">Read More</a><br/></p>
(for the news)
The main content displays fine, but I'm getting this error on the news section...
Notice: Undefined variable: newsRecord in /home/content/s/t/u/stud74/html/jacob/index.php on line 160
Notice: Undefined variable: newsRecord in /home/content/s/t/u/stud74/html/jacob/index.php on line 161
Read More
Here's a link to the site
http://www.interdimensionaldesigns.com/jacob/index.php
I feel like this is a simple fix, but haven't been able to figure it out. Thanks for any help.
John
Interdimensional Designs
www.covdesigns.com
Re: [blind2uriz] Multiple records from different editors on same page
By gkornbluth - April 1, 2011
A likely culprit is the line:
'where' => whereRecordNumberInUrl(1),
in the main get recordds call.
Try removing that and see what you get.
There are a lot of trouble shooting tips and specific coding examples in my CMSB Cookbook at http://www.thecmsbcookbook.com
Hope that solves your issue.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [blind2uriz] Multiple records from different editors on same page
By robin - April 1, 2011
It looks to me like you haven't defined $newsRecord. Try adding this line below your load news section. (A similar line is below your load main section)
$newsRecord = @$newsRecords[0]; // get first record
Hope that helps,
Robin
Programmer
interactivetools.com
Re: [robin] Multiple records from different editors on same page
By blind2uriz - April 1, 2011 - edited: April 1, 2011
Hey Jerry, I bought the cms cookbook yesterday, but I'm not finding any examples so far, still digging around.
Any more thoughts? Do you need me to post anything else code wise? Thanks for all your help.
Interdimensional Designs
www.covdesigns.com
Re: [blind2uriz] Multiple records from different editors on same page
By blind2uriz - April 1, 2011 - edited: April 1, 2011
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/content/s/t/u/stud74/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load records
list($mainRecords, $mainMetaData) = getRecords(array(
'tableName' => 'main',
'where' => whereRecordNumberInUrl(1),
));
$mainRecord = @$mainRecords[0]; // get first record
// show error message if no matching record is found
if (!$mainRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
));
$newsRecord = @$newsRecords[0]; // get first record
?>
and here is what I put in the body....
<?php echo $mainRecord['content'] ?>
<?php echo $newsRecord['title'] ?></p>
<p><?php echo date("D, M jS, Y g:i:s a", strtotime($newsRecord['date'])) ?></p>
<p><a href="<?php echo $newsRecord['_link'] ?>">Read More</a><br/>
Thanks for your info and help. I'm sure I'll need more in the future.
Jerry, I found the info out that helped me in your cookbook.
Thanks,
Interdimensional Designs
www.covdesigns.com
Re: [blind2uriz] Multiple records from different editors on same page
By gkornbluth - April 5, 2011
Glad the CMSB Cookbook www.thecmsbcookbook.com was able to help you solve your problem.
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Multiple records from different editors on same page
By blind2uriz - April 5, 2011
Interdimensional Designs
www.covdesigns.com
Re: [blind2uriz] Multiple records from different editors on same page
By gkornbluth - April 5, 2011
Sounds like you'll need to access the news records editor portion of your code in a list page format and not in a detail page format.
Go to the Code Generator and choose the news records section and click on list page as the viewer type
You'll also see a number of optional parameters that you can apply to the generated viewer code.
You're specifically interested in the "show the first x records only" radio button. Click it and change that to 3.
You can also sort the records in the section editor so that the appropriate ones are shown on your page.
Generate the code and copy the get records code to your viewer. Copy the code in the foreach loop for the fields you want to display to the body of your viewer.
Hope that sets you in the right direction,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Multiple records from different editors on same page
By blind2uriz - April 5, 2011
Interdimensional Designs
www.covdesigns.com