Forum Moderators: not2easy
<div class="product block(1-3)">
<div class="product_image">
<img class="product_img" src="pic.png">
</div>
<p>
<span>Title</span>
<span>100.00 €</span>
</p>
</div>
div.product
{
width:24%;
display:inline-block;
vertical-align:top;
padding:3% 0;
}
div.block1, div.block3
{
margin:0 6%;
}
div.product_img
{
width:100%
}
Maybe I should use tables?Recalling the goal is to separate content from style (layout), this content is always difficult to classify. IMO it could well be treated as tabular data, but also a list, and some extend that to treating title and price as "explaining" the image and use a definition list (maxdesign has an interesting article).
CSS
ul {
margin:0 auto;
padding:0;
width:710px;
list-style-type:none;
}
li {
display:inline-block;
padding:15px;
text-align:center;
width:200px; /*or % for greater flexibility */
}
img, b, a {
display:block;
margin:0 auto;
}
HTML
<ul>
<!--copy 3 times for multiple rows -->
<li><img src="image.jpg" width="100" height="100" alt="My alt"><b>Title</b><a href="#">Price</a></li>
<li><img src="image.jpg" width="10" height="12" alt="My alt"><b>Title</b><a href="#">Price</a></li>
<li><img src="image.jpg" width="180" height="168" alt="My alt"><b>Title</b><a href="#">Price</a></li>
</ul>
<div id="Blocks">
<h1>{l s='Category Name!'}</h1>
{if !isset($i)}
{$i = 1}
{/if}
{if isset($products)}
<!-- Products list -->
{foreach from=$products item=product name=products}
<div class="ajax_block_product {cycle values="Block1,Block2,Block3"}">
<div class="center_block">
<form action="{$product.link|escape:'htmlall':'UTF-8'}" method="post" accept-charset="utf-8" id="form{$i}">
<div>
<input type="hidden" name="products" value="{$products|serialize|base64_encode}" />
{if isset($prev)}<input type="hidden" name="previous" value="{$prev}" />
{elseif isset($previous)}<input type="hidden" name="previous" value="{$previous}" />{/if}
{if isset($categ_id)}<input type="hidden" name="categ_id" value="{$categ_id}" />{/if}
{if isset($search_query)}<input type="hidden" name="search_query" value="{$search_query}" />{/if}
<input type="image" src="{$img_dir}nyhet.png" class="NyhetImg" alt="{l s="Nyhet!"}"/>
<div class="prod_image">
<input type="image" src="{$link->getImageLink($product.link_rewrite, $product.id_image)}" class="ProdImg" alt="{$product.legend|escape:'htmlall':'UTF-8'}"/>
</div>
<input type="submit" value="{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}" alt="{$product.name|escape:'htmlall':'UTF-8'}" />
</div>
</form>
</div>
<div class="right_block">
{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price}<span class="on_sale">{l s='On sale!'}</span>
{elseif isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price}<span class="discount">{l s='Reduced price!'}</span>{/if}
{if !$PS_CATALOG_MODE && isset($product.online_only) && $product.online_only}<span class="online_only">{l s='Online only!'}</span>{/if}
{if ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order))}
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
{if !$PS_CATALOG_MODE && isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif !$PS_CATALOG_MODE && (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}
{/if}
{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}
{if ($product.allow_oosp || $product.quantity > 0) && $product.customizable != 2}
<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart.php')}?add&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>
{else}
<span class="exclusive">{l s='Add to cart'}</span>
{/if}
{/if}
</div>
</div>
{$i = $i + 1}
{/foreach}
<!-- /Products list -->
{/if}
</div>
<div id="Blocks">
<h1>aaaa</h1>
<!-- Products list -->
<div class="ajax_block_product Block1">
<div class="center_block">
<form action="http://example.com/product.php?id_product=2" method="post" accept-charset="utf-8" id="form1">
<div>
<input type="hidden" name="products" value="blah..." />
<input type="hidden" name="previous" value="category" />
<input type="hidden" name="categ_id" value="9" /> <input type="image" src="http://example.com/themes/moblera/img/nyhet.png" class="NyhetImg" alt="Nyhet!"/>
<div class="prod_image">
<input type="image" src="http://example.com/img/p/2-46.jpg" class="ProdImg" alt="iPod shuffle"/>
</div>
<input type="submit" value="iPod shuffle" alt="iPod shuffle" />
</div>
</form>
</div>
<div class="right_block">
<span class="discount">Sänkt pris!</span><span class="price" style="display: inline;">42,57 kr</span><br /></div>
</div>
<div class="ajax_block_product Block2">
<div class="center_block">
<form action="http://example.com/product.php?id_product=7" method="post" accept-charset="utf-8" id="form2">
<div>
<input type="hidden" name="products" value="blah..." />
<input type="hidden" name="previous" value="category" />
<input type="hidden" name="categ_id" value="9" /> <input type="image" src="http://example.com/themes/moblera/img/nyhet.png" class="NyhetImg" alt="Nyhet!"/>
<div class="prod_image">
<input type="image" src="http://example.com/img/p/7-24.jpg" class="ProdImg" alt="iPod touch"/>
</div>
<input type="submit" value="iPod touch" alt="iPod touch" />
</div>
</form>
</div>
<div class="right_block">
<span class="price" style="display: inline;">302,05 kr</span><br /></div>
</div>
<div class="ajax_block_product Block3">
<div class="center_block">
<form action="http://example.com/product.php?id_product=6" method="post" accept-charset="utf-8" id="form3">
<div>
<input type="hidden" name="products" value="blah..." />
<input type="hidden" name="previous" value="category" />
<input type="hidden" name="categ_id" value="9" /> <input type="image" src="http://example.com/themes/moblera/img/nyhet.png" class="NyhetImg" alt="Nyhet!"/>
<div class="prod_image">
<input type="image" src="http://example.com/img/p/6-20.jpg" class="ProdImg" alt=" MacBook Air SuperDrive"/>
</div>
<input type="submit" value="MacBook" alt="MacBook" />
</div>
</form>
</div>
<div class="right_block">
<span class="price" style="display: inline;">1 463,21 kr</span><br /></div>
</div>
<div class="ajax_block_product Block1">
<div class="center_block">
<form action="http://example.com/product.php?id_product=5" method="post" accept-charset="utf-8" id="form4">
<div>
<input type="hidden" name="products" value="blah..." />
<input type="hidden" name="previous" value="category" />
<input type="hidden" name="categ_id" value="9" /> <input type="image" src="http://example.com/themes/moblera/img/nyhet.png" class="NyhetImg" alt="Nyhet!"/>
<div class="prod_image">
<input type="image" src="http://example.com/img/p/5-15.jpg" class="ProdImg" alt="MacBook Air"/>
</div>
<input type="submit" value="MacBook Air" alt="MacBook Air" />
</div>
</form>
</div>
<div class="right_block">
<span class="price" style="display: inline;">1 880,23 kr</span><br /></div>
</div>
<!-- /Products list -->
</div>
#Blocks input.NyhetImg
{
position:absolute;
}
#Blocks input.ProdImg
{
width:100%;
}
#Blocks div.ajax_block_product
{
width:24%;
display:inline-block;
vertical-align:top;
padding:3% 0;
}
#Blocks div.Block1, #Blocks div.Block3, #Blocks div.block1, #Blocks div.block3
{
margin:0 6%;
}
#Blocks div.ajax_block_product input
{
background-color:transparent;
border:none;
color:inherit;
cursor:pointer;
display:inline;
font-size:0.90em;
font-weight:bold;
margin-bottom:5px;
padding:0;
}
#Blocks div.ajax_block_product div.right_block
{
font-size:0.95em;
font-weight:bold;
text-align:right;
}
#Blocks div.ajax_block_product div.right_block span.discount
{
background-color:transparent;
color:#FF0000;
font-size:1.2em;
font-weight:normal;
padding-right:10px;
}
{if !isset($i)}
{$i = 1}
{/if}
{if isset($products)}
<!-- Products list -->
{foreach from=$products item=product name=products}
<div class="product_block {cycle values="Block1,Block2,Block3"}">
<form action="{$product.link|escape:'htmlall':'UTF-8'}" method="post" accept-charset="utf-8" id="form{$i}">
<p>
<input type="hidden" name="products" value="{$products|serialize|base64_encode}" />
{if isset($prev)}<input type="hidden" name="previous" value="{$prev}" />
{elseif isset($previous)}<input type="hidden" name="previous" value="{$previous}" />{/if}
{if isset($categ_id)}<input type="hidden" name="categ_id" value="{$categ_id}" />{/if}
{if isset($search_query)}<input type="hidden" name="search_query" value="{$search_query}" />{/if}
<!--TODO: if new--><input type="image" src="{$img_dir}nyhet.png" class="NyhetImg" alt="{l s="Nyhet!"}"/><!--/if-->
<input type="image" src="{$link->getImageLink($product.link_rewrite, $product.id_image)}" class="ProdImg" alt="{$product.legend|escape:'htmlall':'UTF-8'}"/>
<input type="submit" value="{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}" alt="{$product.name|escape:'htmlall':'UTF-8'}" />
</p>
</form>
{if (isset($product.show_price) && $product.show_price)}<b>{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</b>{/if}
</div>
{$i = $i + 1}
{/foreach}
{/if}
<div class="product_block Block1">
<form action="http://example.com/product.php?id_product=2" method="post" accept-charset="utf-8" id="form1">
<p>
<input type="hidden" name="products" value="blah..." />
<input type="hidden" name="previous" value="category" />
<input type="hidden" name="categ_id" value="9" />
<!--TODO: if new--><input type="image" src="http://81.224.195.198/themes/moblera/img/nyhet.png" class="NyhetImg" alt="Nyhet!"/><!--/if-->
<input type="image" src="http://81.224.195.198/img/p/2-46.jpg" class="ProdImg" alt="iPod shuffle"/>
<input type="submit" value="iPod shuffle" alt="iPod shuffle" />
</p>
</form>
<b>42,57 kr</b></div>
#Blocks input.NyhetImg
{
position:absolute;
}
#Blocks input.ProdImg
{
width:100%;
}
#Blocks div.product_block
{
width:24%;
display:inline-block;
vertical-align:top;
padding:3% 0;
font-size:0.95em;
text-align:right;
}
#Blocks div.product_block form
{
text-align:left;
}
#Blocks div.Block1, #Blocks div.Block3
{
margin:0 6%;
}
#Blocks div.product_block input
{
background-color:transparent;
border:none;
color:inherit;
cursor:pointer;
display:inline;
font-size:0.90em;
font-weight:bold;
margin-bottom:5px;
padding:0;
}
[edited by: engine at 9:51 am (utc) on May 30, 2011]
[edit reason] examplified [/edit]
[edited by: engine at 10:12 am (utc) on Jun 1, 2011]