Multi records

11 posts by 2 authors in: Forums > CMS Builder
Last Post: June 19, 2012   (RSS)

By kdub718 - June 13, 2012

So I have a multi record with different producers thats like a bio about each producer. I would like to figure out a way to add another multi record within each producer where I can list what products they have.

So like basically instead of an upload field or text box etc... can I add another multi record? I'm guessing this isn't possible (although I think it would be a great feature in the future.. hint hint)

If this isn't possible does anyone have any suggestions?

Re: [kdub718] Multi records

By Jason - June 14, 2012

Hi,

The best approach here would be to create a products section to store all your product information. In there, have a list field where you can associate a product with a given producer.

Then, in your producer section, you can add a relatedRecords field that will allow you to see/modify/delete/create records from the products section that were associated with the current producer.

Hope this helps get you started
---------------------------------------------------
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] Multi records

By kdub718 - June 14, 2012

Thanks for the response... I'm kinda a rookie with something this complicated...

I think I understand the first part but I'm not sure I understand how to setup the relatedRecords field. Could you possibly share a little more detail on that?

Re: [Jason] Multi records

By kdub718 - June 15, 2012

SWEEET!!! I think I'm getting it... I appreciate your help!

Beers on me!

Re: [kdub718] Multi records

By kdub718 - June 15, 2012

Well as you can see I got overly excited a little to soon!.. I found what you where talking about and got it show up... but they show up blank and if I create a new record (product) it creates it but I can't see it. Keeps saying no records found but I know its creating it cause it shows it has records in the section editor.

can I email you my admin?

Re: [kdub718] Multi records

By Jason - June 15, 2012

Hi,

Sure, send it in to support@interactivetools.com and I'll take a 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: [Jason] Multi records

By kdub718 - June 19, 2012

So I'm not sure what I've done but it shows all the products for every producer under every producer. How can I define that down so it only shows the products each producer has.

<?php if ($CURRENT_USER): ?>

<table width="523" border="1" bordercolor="#CCCCCC" cellspacing="0" cellpadding="4">
<tr>
<td width="174"><b>Product Name</b></td>
<td width="73"><b>Price</b></td>
<td width="73"><b>In Stock</b></td>
<td width="161"><b></b></td>
</tr>

<?php foreach ($products_naRecords as $record): ?>
<tr>
<td>
<?php echo htmlencode($record['name']) ?><br/>
(Style: <?php echo htmlencode($record['style']) ?>)<br/>
Pack Size: <?php echo htmlencode($record['pack_size']) ?><br/>
</td>
<td><?php echo htmlencode($record['price']) ?></td>
<td><?php echo htmlencode($record['quantity']) ?></td>
<td>

<!-- add to cart -->
<?php
$formName = "addform" . $record['num'];
$cartItems = array(
array(
'name' => $record['name'],
'unitPrice' => $record['price'],
'recordNum' => $record['num'],
'tableOrTag' => 'products_na',
'quantity=' => '_sc_quantity',
),
//array('name' => 'Color: Blue', 'OPTION' => TRUE),
//array('name' => 'Region: North', 'OPTION' => TRUE),
//array('name' => 'Size: Xl', 'OPTION' => TRUE),
);
?>
<form method="post" name="<?php echo $formName ?>" action="?">
<input type="hidden" name="_sc_action" value="add">
<input type="hidden" name="_sc_nextUrl" value="?">
<?php sc_createAddFormData($cartItems); ?>

<input type="text2" name="_sc_quantity" size="5" maxlength="5" value="0" /><br/>
<a href="#" title="Add to Cart" class="addToCart" onclick="document.forms.<?php echo $formName ?>.submit(); return false;">Add to Cart</a><br />
</form>
<!-- /add to cart -->

</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>

<p>
<?php if (!$north_americaRecord): ?>
No record found!<br/><br/>
<?php endif ?>

Re: [kdub718] Multi records

By Jason - June 19, 2012

Hi,

Could you attach your entire .php file so we can see how your record sets are being produced?

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: [Jason] Multi records

By kdub718 - June 19, 2012 - edited: June 19, 2012

Here you go! I took out everything that didn't apply to clean it up...

Also when I select a qty to add to cart it only adds 1 even if I select 5. So not sure why that is either...

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

// load viewer library
$libraryPath = 'lib/viewer_functions.php';
$dirsToCheck = array('...');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

list($north_americaRecords, $north_americaMetaData) = getRecords(array(
'tableName' => 'north_america',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$north_americaRecord = @$north_americaRecords[0]; // get first record

// load records from 'products_na'
list($products_naRecords, $products_naMetaData) = getRecords(array(
'tableName' => 'products_na',
'loadUploads' => true,
'allowSearch' => false,
));

// error checking
$errorsAndAlerts = alert();
if (@$CURRENT_USER) {
$errorsAndAlerts = "You are already logged in!";
}

// Tally cart!
list($grandTotal, $subTotal, $extraLineItems, $talliedCartItems) = sc_tallyCart();

?>

<!-- _________________________ Start Content _________________________ -->
<div id="content">
<div id="producerDB" class="clearfix">
<div id="leftProducer">
<?php foreach ($north_americaRecord['picture'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt='' /><br/>
<br/>
<?php endif ?>
<?php endforeach ?>
<?php if(!$north_americaRecord['picture']): ?>
<img src="images/default-product-image.jpg" alt="" />
<?php endif ?>
</div>
<!-- End selections -->
<div id="rightProducer">
<h2><img src="images/<?php echo $north_americaRecord['product'] ?>_icon.png" align="absmiddle"/><?php echo $north_americaRecord['name'] ?></h2>

<p><?php echo $north_americaRecord['description'] ?></p>

<?php if ($CURRENT_USER): ?>

<table width="523" border="1" bordercolor="#CCCCCC" cellspacing="0" cellpadding="4">
<tr>
<td width="174"><b>Product Name</b></td>
<td width="73"><b>Price</b></td>
<td width="73"><b>In Stock</b></td>
<td width="161"><b></b></td>
</tr>

<?php foreach ($products_naRecords as $record): ?>
<tr>
<td>
<?php echo htmlencode($record['name']) ?><br/>
(Style: <?php echo htmlencode($record['style']) ?>)<br/>
Pack Size: <?php echo htmlencode($record['pack_size']) ?><br/>
</td>
<td><?php echo htmlencode($record['price']) ?></td>
<td><?php echo htmlencode($record['quantity']) ?></td>
<td>

<!-- add to cart -->
<?php
$formName = "addform" . $record['num'];
$cartItems = array(
array(
'name' => $record['name'],
'unitPrice' => $record['price'],
'recordNum' => $record['num'],
'tableOrTag' => 'products_na',
'quantity=' => '_sc_quantity',
),
//array('name' => 'Color: Blue', 'OPTION' => TRUE),
//array('name' => 'Region: North', 'OPTION' => TRUE),
//array('name' => 'Size: Xl', 'OPTION' => TRUE),
);
?>
<form method="post" name="<?php echo $formName ?>" action="?">
<input type="hidden" name="_sc_action" value="add">
<input type="hidden" name="_sc_nextUrl" value="?">
<?php sc_createAddFormData($cartItems); ?>

<input type="text2" name="_sc_quantity" size="5" maxlength="5" value="0" /><br/>
<a href="#" title="Add to Cart" class="addToCart" onclick="document.forms.<?php echo $formName ?>.submit(); return false;">Add to Cart</a><br />
</form>
<!-- /add to cart -->

</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>

<p>
<?php if (!$north_americaRecord): ?>
No record found!<br/><br/>
<?php endif ?>
</p>
</div>
</div><!-- End content -->
</div>
<!-- _________________________ Finish Content _________________________ -->

</body>
</html>