Multiple records from different editors on same page

9 posts by 3 authors in: Forums > CMS Builder
Last Post: April 5, 2011   (RSS)

I've look over the forums to try and figure this out, but haven't gotten it to work yet. I have my index.php page that I want to display "main content" on and "current news" on as well. How do I go about this? I have a section editor of the main content, as well as a section editor for the news. The header code is...

<?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
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [blind2uriz] Multiple records from different editors on same page

By gkornbluth - April 1, 2011

Hi John,

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
The first CMS Builder reference book is now available on-line!







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

Hey John,

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
Robin
Programmer
interactivetools.com

Re: [robin] Multiple records from different editors on same page

By blind2uriz - April 1, 2011 - edited: April 1, 2011

I tried both solutions but no change.

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.
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [blind2uriz] Multiple records from different editors on same page

By gkornbluth - April 5, 2011

Hi John,

Glad the CMSB Cookbook www.thecmsbcookbook.com was able to help you solve your problem.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







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

Thanks Jerry, it has. I do have another problem that seems like it might be easy, w/ the same code, I'm trying to get more than one "News" event to show on the page, actually I want 3 to show. How would I go about this, I can't seem to find an answer. Thanks for any help
John C. Morris
Interdimensional Designs
www.covdesigns.com

Re: [blind2uriz] Multiple records from different editors on same page

By gkornbluth - April 5, 2011

Hi John,

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
The first CMS Builder reference book is now available on-line!







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

Got it! Thanks Jerry.
John C. Morris
Interdimensional Designs
www.covdesigns.com