Multi records
11 posts by 2 authors in: Forums > CMS Builder
Last Post: June 19, 2012 (RSS)
By kdub718 - June 13, 2012
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
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
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: [kdub718] Multi records
By Jason - June 15, 2012
relatedRecords is an advanced field. You can add it like any other field to your section. It will ask you which section you are connecting to (in your case, products) and select some options. You then have to add in a WHERE clause that will connect it to your products section. I've attached an example screen shot of what the field might look like. In this example, we assumed that the products section had a field called "producer" and that the value of the producer field is the "num" field of the producer record.
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] Multi records
By kdub718 - June 15, 2012
Beers on me!
Re: [kdub718] Multi records
By kdub718 - June 15, 2012
can I email you my admin?
Re: [kdub718] Multi records
By Jason - June 15, 2012
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
<?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
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
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>