[CODE]
I am building an ecommerce website with the aid of the book Beginning PHP and MySQL E-Commerce: From Novice to Professional 2nd edition. This book uses smarty tpl files along with php files. It also uses yui css files. My problem is as follows.
I am using a file called product-list.tpl as a template to display my products. Using code from this book, I am unable to display more than 2 products per line. In other words, I am unable to display more than 2 table cells per row. Here is the code I am using to display products in product-list.tpl:
[CODE]{if $obj->mProducts}
<table class=”product-list” border=”0″>
<tbody>
{section name=k loop=$obj->mProducts}
{if $smarty.section.k.index % 2 == 0}
<tr>
{/if}
<td valign=”top”>
<p>
{if $obj->mProducts[k].thumbnail neq “”}
<a href=”{$obj->mProducts[k].link_to_product}”>
<img src=”{$obj->mProducts[k].thumbnail}”
alt=”{$obj->mProducts[k].name}” />
</a>
{/if}
</p>
<p class=”product-title”>
<a href=”{$obj->mProducts[k].link_to_product}”>
{$obj->mProducts[k].name}
</a>
</p>
<p class=”section”>
Price:
{if $obj->mProducts[k].discounted_price != 0}
<span class=”old-price”>{$obj->mProducts[k].price}</span>
<span class=”price”>{$obj->mProducts[k].discounted_price}</span>
{else}
<span class=”price”>{$obj->mProducts[k].price}</span>
{/if}
</p>
{* Show Edit button for administrators *}
{if $obj->mShowEditButton}
<form action=”{$obj->mEditActionTarget}” target=”_self”
method=”post” class=”edit-form”>
<input type=”hidden” name=”product_id”
value=”{$obj->mProducts[k].product_id}” />
<input type=”submit” name=”submit” value=”Edit Product Details” />
</form>
{/if}
</td>
{if $smarty.section.k.index % 2 != 0 && !$smarty.section.k.first ||
$smarty.section.k.last}
</tr>
{/if}
{/section}
</tbody>
</table>
The CSS for this is as follows:
[CODE].product-list tbody tr td {
border: none;
padding: 5px;
width: 150px;
}
.product-list tbody tr td p img {
border: none;
margin: 0 10px;
vertical-align: top;
}
I looked through all the yui css and there was nothing that would affect a table td or tr. When using tables in the past with css I had always built the entire table and used the css to style the table. I no nothing in css that can limit table cells. If there is something, it isn’t used in any of the CSS I’m using. This leaves me with smarty. I looked all through out smarty to see if something in the Smarty_Compiler.class.php was limiting how many times the products could loop in one row. But I really don’t understand smarty.
I need to fit four products per line and despite all my efforts of messing with td width only two can fit in one row before the products go to the next row. Does anyone know why this is? Please help, I’m very confused.