Hi Terry,
Have you played with the free relatedrecordslookup plugin at all?
Here's an excerpt from the next update of my CMSB Cookbook
http://www.thecmsbcookbook.com that may help in this situation:
POPULATING PAGES FROM A MASTER “ADDRESS BOOK” OR “PRODUCT LIST”Let’s say you have a number of address book entries that contain things like name, address, phone, travel directions, map URL, etc. Or you have a number of products with detailed information about them.
Instead of retyping all of your information each time you want to display it on a detail page, you can pull that information directly from your master information list. Chris from Interactive Tools created a “relatedRecordLookupFunctions” plugin to add the required functionality this and suggested the following approach, I modified the table and field names for this “Address Book” example:
MULTI-VALUE LIST FIELDS (THE CODE REQUIRED FOR SINGLE VALUE LIST FIELDS FOLLOWS)Step 1: Set up your address book section. for this example call it “Venue Address Book”.
This is a standard multi-record section with the necessary information fields. Since this example is an address book of venues for an events listing, I’ve set up fields for Venue Name, Venue Address, Venue Phone, Venue Contact E-mail, Venue URL, Venue URL link text (I like to keep these separate to add flexibility for my clients but I set the default text to WEB SITE or CLICK HERE FOR WEB SITE), Venue Travel Directions, and Venue Map URL (either from Mapquest or Google maps).
Step 2: In the section where you want this information to appear you’ll add a list type field called “Venue” with the following parameters.
Field Label: Venue
Field Name: venue
Field Type: list
Field Options:
Display As: pulldown or checkbox (multi-value)
List Options: Get options from database (advanced)
Section Tablename: venue_address_book
Use this field for option values: num
Use this field for option labels: venue_name
Step 3: Install the Related Record Lookup Functions Plugin which you can download from:
www.thecmsbcookbook.com/downloads/relatedRecordLookupFunctions.zipUpload the file to your server in the /cmsAdmin/plugins directory, then log into CMSB, go to Admin > Plugins, and click Activate on it.
Step 3: To set up your viewer to display the fields required you'll need to add some code to the top of your page. You probably already have most the code in black in your PHP source code. Just add the code in red:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
require_once "/your_path_to/cmsAdmin/lib/viewer_functions.php";
list($e_blast_events_noticeRecords, $e_blast_events_noticeMetaData) = getRecords(array(
'tableName' => 'e_blast_events_notice',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
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
// show error message if no matching record is found
if (!$e_blast_events_noticeRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
?>
<!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">
Step 4: Then in the body, where you want to display your address book fields:
<?php if (empty($e_blast_events_noticeRecord['venue'])): ?>
No Venue Information is available.
<?php else: ?>
<div align="left"> Venue Information: <br />
<?php foreach ($e_blast_events_noticeRecord['venue'] as $venue): ?>
<?php echo $venue['venue_name'] ?><br />
<?php echo $venue['venue_address'] ?><br />
<?php echo $venue['venue_contact_e_mail'] ?> <br />
<?php echo $venue['venue_phone'] ?><br />
Directions: <br /><?php echo $venue['venue_travel_directions'] ?> <br />
<a href="<?php echo $venue['venue_map'] ?>">CLICK HERE FOR A MAP</a> <br />
<a href="<?php echo $venue['venue_url'] ?>"><?php echo $venue(venue_url_link_text); ?></a><br/>
<?php endforeach ?>
</div>
<?php endif ?>
You can display the fields separately but you’ll need a foreach loop for each field or set of fields that you want to display.
SINGLE VALUE LIST FIELDS According to Chris, “The process works with single value lists too, but the interface is slightly different. The plugin replaces the field with the associated record, instead of a list of records. For this reason, you wouldn't use foreach to loop over the records.”
Here’s how. First, define the variable $venue before it's first use:
<?php $venue = $e_blast_events_noticeRecord['venue']; ?>
Then where you want to echo the fields in your viewer:
<?php echo $venue['venue_name']; ?>
And if you wanted to include an “if” statement the code would look like this:
<?php if ($venue['venue_name']): ?>
<?php echo $venue['venue_name']; ?>
<?php endif; ?>
Or you could leave out the define variable step and just use:
<?php echo $e_blast_events_noticeRecord['venue']['venue_name']; ?>
Of course, as always, styling is up to you.
Maybe this will help...
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