17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2150 Views |
-
Using a custom array inside a <% control property %>

2 October 2007 at 6:29am
Hey there,
Ik got a function which creates an array based on form fields on the page before.
Now with that array i want a simple foreach kind a thing in the template, i know i'm close, but could anyone help me a step further?
Here's the php
if ($_POST['Intermediair_250'] > 0) {
$producten[]['product'] = 'Intermediar pakket 250';
$producten[]['prijs_totaal'] = $_POST['Intermediair_250'] * 2697;
$producten[]['prijs_per_stuk'] = 2697;
}
if ($_POST['Intermediair_1000'] > 0) {
$producten[]['product'] = 'Intermediar pakket 1000';
$producten[]['prijs_totaal'] = $_POST['Intermediair_1000'] * 7188;
$producten[]['prijs_per_stuk'] = 7188;
}
$totaalprijs = 0;
foreach ($producten as $product) {
$totaalprijs = $totaalprijs + $product['prijs_totaal'];
}
$doProducten = new DataObjectSet();
$doProducten->producten = new ArrayData($producten);
$data = array(
"Title" => "Mijn bestelling",
"producten" => $doProducten,
"totaalprijs" => $totaalprijs
);And then in the template :
<% control producten %>
<tr>
<td class="icon"><img src="empex/images/shoppingcart.jpg" width="25" height="23" /></td>
<td class="Producten">$product</td>
<td class="Aantal"></td>
<td class="Categorie"></td>
<td class="Credits"></td>
<td class="Geldigheid"></td>
</tr>
<% end_control %>so i want to iterate producten, but how?
Thanks!
-
Re: Using a custom array inside a <% control property %>

2 October 2007 at 9:50pm Last edited: 2 October 2007 10:06pm
Got it to work! with the help of Matt!!
check it out!
$producten = new DataObjectSet();
if ($_POST['vacature_laag'] > 0) {
$producten->push(new ArrayData(array('product' => 'Vacature(s) categorie 1',
'prijs_totaal' => $_POST['vacature_laag'] * 30,
'prijs_per_stuk' => 30)));
}
if ($_POST['vacature_hoog'] > 0) {
$producten->push(new ArrayData(array('product' => 'Vacature(s) categorie 2',
'prijs_totaal' => $_POST['vacature_hoog'] * 109,
'prijs_per_stuk' => 109)));
}
if ($_POST['Intermediair_100_stage'] > 0) {
$producten->push(new ArrayData(array('product' => 'Intermediar pakket 100 stage',
'prijs_totaal' => $_POST['Intermediair_100_stage'] * 990,
'prijs_per_stuk' => 990)));
}
if ($_POST['Intermediair_100'] > 0) {
$producten->push(new ArrayData(array('product' => 'Intermediar pakket 100',
'prijs_totaal' => $_POST['Intermediair_100'] * 999,
'prijs_per_stuk' => 999)));
}
if ($_POST['Intermediair_250'] > 0) {
$producten->push(new ArrayData(array('product' => 'Intermediar pakket 100',
'prijs_totaal' => $_POST['Intermediair_250'] * 2697,
'prijs_per_stuk' => 2697)));
}
if ($_POST['Intermediair_1000'] > 0) {
$producten->push(new ArrayData(array('product' => 'Intermediar pakket 1000',
'prijs_totaal' => $_POST['Intermediair_1000'] * 7188,
'prijs_per_stuk' => 7188)));
}
$data = array(
"Title" => "Mijn bestelling",
"producten" => $producten,
);
| 2150 Views | ||
|
Page:
1
|
Go to Top |

