Prev | Current Page 274 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

Add the highlighted piece of code to the init() method in presentation/products_list.php. This
displays the list of attributes for each product in the list.
// Build links for product details pages
for ($i = 0; $i < count($this->mProducts); $i++)
{
$this->mProducts[$i]['link_to_product'] =
Link::ToProduct($this->mProducts[$i]['product_id']);
if ($this->mProducts[$i]['thumbnail'])
$this->mProducts[$i]['thumbnail'] =
Link::Build('product_images/' . $this->mProducts[$i]['thumbnail']);
$this->mProducts[$i]['attributes'] =
Catalog::GetProductAttributes($this->mProducts[$i]['product_id']);
}
}
}
?>
3. Open the presentation/templates/product.tpl file, and add the highlighted code, which generates
the list of attribute values for the product details page:


Price:
{if $obj->mProduct.discounted_price != 0}
{$obj->mProduct.price}
{$obj->mProduct.discounted_price}
{else}
{$obj->mProduct.price}
CHAPTER 6 ?–  PRODUCT ATTRIBUTES 183
{/if}


{* Generate the list of attribute values *}


{* Parse the list of attributes and attribute values *}
{section name=k loop=$obj->mProduct.attributes}
{* Generate a new select tag? *}
{if $smarty.section.k.first ||
$obj->mProduct.attributes[k].attribute_name !==
$obj->mProduct.


Pages:
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286

Wczasy Jastrzębia Góra zalew sulejowski jarosławiec online cash loans kolej transsyberyjska