ADDING FEATURED PERFORMERS FROM A MASTER DATABASE TO AN EVENT RECORD VIEWER - Jan 28th, 2021


ADDING FEATURED PERFORMERS TO AN EVENT RECORD
For Jazz on J Street events, my client wanted me to create a multi record ‘musicians_listing’ section to contain
images and information about each musician who had performed at their events.

I wanted to be able to access that information on my client’s events pages as well. To accomplish that, I chose to
use the new ‘Pillbox’ list field format to list the featured performers for each event.

Since you can’t rearrange the current ‘pills’ in a pillbox field, I used a custom pillbox plugin available in the
‘Packaged Solutions’ section of this website at: http://thecmsbcookbook.com/templates_detail.php?4 The plugin adds
the ability to drag the position of pills in the pillbox. (This is a function that may, or may not be added to a future
CMSB release.)

To populate specific ‘events’ and listen_live listings with the information in the ‘musicians_listings’ section
in (described below), I used the beta_lookupRelatedFields plugin, a free plugin available at
http://thecmsbcookbook.com/downloads/relatedRecordLookupFunctions.zip Using the Related records plugin is covered in the
recipe at http://thecmsbcookbook.com/recipedetail.php?273 but I’ll also include the required code in this recipe.

The first thing is a multi record editor which I called ‘Musicians Listings’.This editor has a record for each
musician or group that’s performing. It has ‘text’ fields for the musician’s ‘first_name’,
‘middle_name’, ‘last_name’, ‘full_performer_or_group_name, ‘instruments_ played’, and ‘description’,
and an upload field for a performer image. Note: Every performer must have their ‘full_performer_or_group_name’
field filled in for this scheme to work.

To set up my pillbox I added a ‘list’ field called ‘performers’ to both my ‘listen_live’ streamed event
listings editor and my ‘events’ listing editor. I chose pillbox (multi value) as the ‘Display As’ type, chose
‘Get options from database (advanced)’ as the list options type and used the ‘num’ field as the option values
and the ‘full_performer_or_group_name’ for the option labels.

You can display the new pillbox information in a viewer with this simple code taken from the code generator, but that
will only display the values of the ‘full_performer_or_group_name field from the ‘performers’ pillbox field in the
‘listen_live’ or ‘events’records.

<?php echo join(', ', $listen_liveRecord['pills:labels']); ?>


The real magic comes in when you can show the data stored in other fields in the ‘musicians_listings’section records
the in the ‘events’ or ‘listen_live’ viewers. Or create live links in those viewers to the complete
musicians_listings’ record for that performer. Thanks to some help from Interactive tools programmer Carl Wuensche ,wa
sable to accomplish that for both list pages and detail pages with the code below .

For a list page of your ‘listen_live records you could use the following:

At the top of your page the load records call for the ‘musucians_listings’

// load records from 'musicians_lisings'
list($musicians_lisingsRecords, $musicians_lisingsMetaData) = getRecords(array(
'tableName' => 'musicians_lisings',
'loadUploads' => true,
'allowSearch' => false,
));


And in the body where you want to show the ‘listen_live’ record information with the related record pillbox
information, use the code below:

NOTE: The where statement will only show events with a ‘presentation_date’ coming up in the next 31 days. You can
comment that out, or change it to reflect your specific needs. If you want to show listings from another group, copy the
entire code block again and change the where statement to your reflect your specific needs.
Some examples are:
This weeks events

'where' => '((NOW() + INTERVAL 7 DAY) >= presentation_date AND presentation_date >= TIMESTAMP(CURDATE(), "00:00:00"))',

Past Events:

'where' => 'presentation_date <= TIMESTAMP(CURDATE(), "00:00:00"),

Events more than 31 days in the future

'where' => 'presentation_date <= presentation_date > TIMESTAMP(NOW()+ INTERVAL 31 DAY)',




<!-- BEGIN PERFORMER LISTING CODE -->
<?php // only retrieve records where the presentation date is within the upcoming 31 days
list($listen_liveRecords, $listen_liveMetaData) = getRecords(array(
'tableName' => 'listen_live',
'where' => '((NOW() + INTERVAL 31 DAY) >= presentation_date AND presentation_date >= TIMESTAMP(CURDATE(),
"00:00:00"))',

'orderBy'=> 'presentation_date ASC',
));

beta_lookupRelatedFields(array(
'table' => 'listen_live',
'recordList' => &$listen_liveRecords,
'fieldList' => array( 'performers' )

));
$listen_liveRecord = @$listen_liveRecords[0]; // get first record
?>
<table width="100%" border="0" align="center">
<?php foreach ($listen_liveRecords as $record): ?>
<?php // Your Event Name, Date, and Time Information Goes Here ?>

<?php if ( !empty($record['performers'])):?>
<?php foreach ($record['performers'] as $performer):?>
<tr>
<td width="25%"><a href="musicians_detail.php?<?php echo $performer['num'] ?>">
<?php foreach ($performer['list_page_image'] as $upload): ?>
<img style="padding-right: 10px; border:hidden" src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo
$upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php endforeach ?> </a>
</td>
<td><span class="sub_heading_font">Featuring: </span><a href=”musicians_detail.php?<?php echo $performer['num']
?>"><span class="sub_heading_font" style="text-decoration:underline"> <?php $full_performer_or_group_name =
strtolower($performer['full_performer_or_group_name']);
echo
ucwords($full_performer_or_group_name) ?> - <?php echo $performer['medium'] ?></span> </a>
</td>
</tr>
<tr>
<td colspan="2"><hr />
</td>
</tr>
<?php endforeach ?>
<?php endif ?>
<!-- END PERFORMER LISTING CODE -->
<?php endforeach ?>
</table>


For an ‘events’ detail page where you’re getting the record number from the end of the URL, the code is a bit
different:

At the top of the page:


// load record from 'listen_live'
list($listen_liveRecords, $listen_liveMetaData) = getRecords(array(
'tableName' => 'listen_live',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$listen_liveRecord = @$listen_liveRecords[0]; // get first record

// load records from 'musicians_lisings'
list($musicians_lisingsRecords, $musicians_lisingsMetaData) = getRecords(array(
'tableName' => 'musicians_lisings',
'loadUploads' => true,
'allowSearch' => false,
// 'orderBy' => 'concert_lineup_order DESC',
));

beta_lookupRelatedFields(array(
'table' => 'listen_live',
'recordList' => &$listen_liveRecords,
'fieldList' => array( 'performers' )

));
$listen_liveRecord = @$listen_liveRecords[0]; // get first record
?>


And in the body of the page where you want to show the event information:

<?php // Your Expanded Event Name, Date, Time and Event Description Information Goes Here ?>

<!-- BEGIN PERFORMER LISTING CODE -->
<?php if (!empty($listen_liveRecord['performers'])): ?>
<table>
<tr>
<td><span class="heading_font">
Learn More About This Month's Featured Performers:</span></td>
</tr>
<tr>
<td ><hr /></td>
</tr>
<?php foreach ($listen_liveRecord['performers'] as $performer): ?>
<tr>
<td width="25%"><a href="musicians_detail.php?<?php echo $performer['num'] ?>">
<?php foreach ($performer['list_page_image'] as $upload): ?>
<img style="padding-right: 10px; border:hidden" src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo
$upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php endforeach ?></a>
<a href="musicians_detail.php?<?php echo $performer['num'] ?>"><span style="text-decoration:underline"> <?php echo
$performer['full_performer_or_group_name'] ?> - <?php echo $performer['instruments'] ?></span> </a></td>
</tr>
<tr>
<td >
<hr />
</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
<!-- END PERFORMER LISTING CODE -->




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service