LIST RECORDS WHERE AUTHOR OF RECORDS IN TABLE 1 RECORDS MATCH AUTHOR OF RECORDS IN TABLE 2 - Jul 24th, 2011
|
If a member-user uploaded a custom masthead, I needed to display that masthead in a detail viewer. However, I wanted to display each user's masthead only on records that they had created.
Here's how...
I already had a multi-record editor called subscription_pages that contained all of the records created by each member-user.
In order to add custom mastheads:
1) Create a multi-record editor called "custom_branding" with only one record allowed per user. The only field in this editor is an upload field for their custom masthead.
2) To the standard records calls:
list($subscription_pagesRecords, $subscription_pagesMetaData) = getRecords(array( 'tableName' => 'subscription_pages', 'where' => whereRecordNumberInUrl(1), 'limit' => '1', )); $subscription_pagesRecord = @$subscription_pagesRecords[0]; // get first record
Add the following to define the variable $owner (add this below the subscription_pages call or you'll get a undefined variable error)
$owner = $master_subscription_pagesRecord['createdByUserNum'];
Then change the where statement to restrict the records called to only those where the author's of the custom branding record (the masthead) matches the subscription_pages records
// load records list($custom_brandingRecords, $custom_brandingMetaData) = getRecords(array( 'tableName' => 'custom_branding', 'where' => 'createdByUserNum = "'. $owner .'"' , 'limit' => '1', )); $custom_brandingRecord = @$custom_brandingRecords[0]; // get first record
Finally in the body where you want to display the custom masthead:
<?php if ($custom_brandingRecord['masthead'] && ($custom_brandingRecord['createdByUserNum'] == $master_subscription_pagesRecord['createdByUserNum'])) : ?><?php foreach ($custom_brandingRecord['masthead'] as $upload): ?><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><?php endforeach ?> <?php else : ?> <img src="your_standard_masthead.jpg" /> <?PHP endif ?>
For testing purposes, you can add:
Custom Branding owner: <?php echo $custom_brandingRecord['createdByUserNum'] ?> <br /> Subscription Page owner: <?php echo $master_subscription_pagesRecord['createdByUserNum'] ?>
|
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.