Professional CodeIgniter, Thomas Myer

Chapter 7: Improving the Dashboard
231
$data[`title'] = "Claudia's Kids | ". $product[`name'];
$data[`main'] = `product';
$data[`navlist'] = $this-
>
MCats-
>
getCategoriesNav();
$data[`assigned_colors'] = $this-
>
MProducts-
>
getAssignedColors($productid);
$data[`assigned_sizes'] = $this-
>
MProducts-
>
getAssignedSizes($productid);
$data[`colors'] = $this-
>
MColors-
>
getActiveColors();
$data[`sizes'] = $this-
>
MSizes-
>
getActiveSizes();
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`template');
}

In other words, you ' re going to reuse the model functions and resulting data arrays on the public side.
To make these lists appear, simply loop through
$assigned_colors

and
$assigned_sizes

and then
look up the names in
$colors

and
$sizes

on the product view.
Here ' s the entire view again, to refresh your memory, with the specific code in bold:
<
div id='pleft'
>
<
?php
if ($this-
>
session-
>
flashdata(`conf_msg')){ //change!
echo "
<
div class='message'
>
";
echo $this-
>
session-
>
flashdata(`conf_msg');
echo "
<
/div
>
";
}
?
>
<
?php
echo "
<
img src='".$product[`image']."' border='0' align='left'/
>
\n";
echo "
<
h2
>
".$product[`name']."
<
/h2
>
\n";
echo "
<
p
>
".$product[`longdesc'] . "
<
br/
>
\n";
echo "Colors: ";
foreach ($assigned_colors as $value){
echo $colors[$value] . "
&
nbsp;";
}
echo "
<
br/
>
";
echo "Sizes: ";
foreach ($assigned_sizes as $value){
echo $sizes[$value] . "
&
nbsp;";
}
echo "
<
br/
>
";
echo anchor(`welcome/cart/'.$product[`id'],'add to cart') . "
<
/p
>
\n";
?
>
<
/div
>
<
div id='pright'
>
<
?php
foreach ($grouplist as $key =
>
$list){
echo "
<
div class='productlisting'
>
<
img src='".$list[`thumbnail']."'
border='0' class='thumbnail'/
>
\n";
echo "
<
h4
>
".$list[`name']."
<
/h4
>
\n";
c07.indd 231
c07.indd 231
6/10/08 5:36:55 PM
6/10/08 5:36:55 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.