Echo details from another section??

36 posts by 5 authors in: Forums > CMS Builder
Last Post: May 31, 2010   (RSS)

By gkornbluth - May 27, 2010 - edited: May 28, 2010

Ii Chris,

The plugin has been working perfectly on my detail pages but this is the first time that I've tried to use it on a list page.

On the list page, using the code below, it pulls the venue_name etc., from all the related field records into each event record. (The lookup for the detail page in this set works as expected.)

I know that the inner foreach loop is the culprit, and that I must be missing something simple (as always) but I’m not having any luck figuring it out.

The lookup is from a single value list field.

Thanks,

Jerry Kornbluth

Here’s the code at the head of the list page:

list($e_blast_events_noticeRecords, $e_blast_events_noticeMetaData) = getRecords(array(
'tableName' => 'e_blast_events_notice',
));

beta_lookupRelatedFields(array(
'table' => 'e_blast_events_notice',
'recordList' => &$e_blast_events_noticeRecords,
'fieldList' => array( 'venue' )
));

$e_blast_events_noticeRecord = @$e_blast_events_noticeRecords[0]; // get first record


And here’s the code I;m using to display the information

<?php foreach ($e_blast_events_noticeRecords as $record): ?>
<?php if ($record['event_title']): ?><br /><br />

<?php foreach ($e_blast_events_noticeRecords as $record): ?>

<?php $venue = $record['venue']; ?>

Location:</span><br />
<?php echo $venue['venue_name']; ?><br />
<?php echo $venue['venue_address'] ?><br />
<?php endforeach; ?>
<?php endforeach; ?>
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] Echo details from another section??

By Jason - May 31, 2010

Hi Jerry,

I've been looking over this. So the problem is that for each event displayed, it's displaying all related records, not just the related record specific to that event. Is that right?

If so, I think you won't need your inner foreach loop. It looks like what's happening is that for each event, you have a second loop displaying all the venue names of each event.

Try this code instead:

<?php foreach ($e_blast_events_noticeRecords as $record): ?>
<?php if ($record['event_title']): ?><br /><br />

<?php $venue = $record['venue']; ?>

Location:</span><br />
<?php echo $venue['venue_name']; ?><br />
<?php echo $venue['venue_address'] ?><br />
<?php endforeach; ?>


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Echo details from another section??

By gkornbluth - May 31, 2010

Hi Jason,

Thanks for getting into this.


I gave your suggestion a try and for each record displayed on the page it now shows a list of all the related records (plus a few strange fields)

There are only 2 events showing on the working page. A real one (location should be the Crest Theater) and a test event (location should be Craft Gallery)

This is the working page without the related records code in the body:
http://www.artistsofpalmbeachcounty.org/member_access/exhibitionsubmission.php

And the non working page with the related records code: http://www.artistsofpalmbeachcounty.org/member_access/exhibitionsubmission3.php

A copy of the entire page is attached if it will help, but this is the code at the top of the page:<?php

require_once "/hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/lib/viewer_functions.php";

list($e_blast_events_noticeRecords, $e_blast_events_noticeMetaData) = getRecords(array(
'tableName' => 'e_blast_events_notice',


));

list($become_a_memberRecords, $become_a_memberMetaData) = getRecords(array(
'tableName' => 'become_a_member',

'limit' => '1',
));
$become_a_memberRecord = @$become_a_memberRecords[0]; // get first record

beta_lookupRelatedFields(array(
'table' => 'e_blast_events_notice',
'recordList' => &$e_blast_events_noticeRecords,
'fieldList' => array( 'venue' )

));
$e_blast_events_noticeRecord = @$e_blast_events_noticeRecords[0]; // get first record
?>


And the code you suggested that's pulling up the records:<?php foreach ($e_blast_events_noticeRecords as $record): ?>


<?php $venue = $record['venue']; ?>

Location:</span><br />
<?php echo $venue['venue_name']; ?><br />
<?php echo $venue['venue_address'] ?><br />
<?php endforeach; ?>


Thanks,

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
Attachments:

exhibitionsubmission3.php 17K

Re: [gkornbluth] Echo details from another section??

By Jason - May 31, 2010

Hi Jerry,

If you could email me CMS and FTP login details to jason@interactivetools.com, I can take a closer look.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [gkornbluth] Echo details from another section??

By Jason - May 31, 2010

Hi Jerry,

Since you're only returning one record, there is no need for a foreach loop at all. This code should work better:

<?php $venue = $e_blast_events_noticeRecord['venue']; ?>


Location:</span><br />
<?php echo $venue['venue_name']; ?><br />
<?php echo $venue['venue_address'] ?><br />


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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