1
Bleekk
oledrion shop - display products in 3 colums
  • 2008/8/31 21:11

  • Bleekk

  • Theme Designer

  • Posts: 941

  • Since: 2002/12/14


hi all,
I would like to display the products on the shop index page in 3 columns but I do not how

here the relevant code:
<{if count($products) > 0}>
    <
div class="featured-blocks-titles"><h2><img src="<{$smarty.const.OLEDRION_IMAGES_URL}>icon-product-person.png" alt="<{$smarty.const._OLEDRION_CART}>" border="0" /><{$smarty.const._OLEDRION_MOST_RECENT}>h2>div>
    <
table border="0" class="oledrion_productindex">
    <{foreach 
item=product from=$products}>
    <
tr>
        <
td class="oledrion_productthumb"><{if $product.product_thumb_url}><a href="<{$product.product_url_rewrited}>" title="<{$product.product_href_title}>"><img src="<{$product.product_thumb_full_url}>" alt="<{$product.product_href_title}>" border="0" />a><{/if}>td>
        <
td class="oledrion_productssummary">

        <
table width="100%" cellspacing="0">
      <
tr>
        <
td class="page-curl_01">
            <
div class="oledrion_producttitle"><{$product.product_recommended_picture}><a href="<{$product.product_url_rewrited}>" title="<{$product.product_href_title}>"><{$product.product_title}>a>div><div class="oledrion_productauthor"><{if $product.product_joined_manufacturers != ''}><img src="<{$smarty.const.OLEDRION_IMAGES_URL}>author.png" alt="" border="0" /><{$smarty.const._OLEDRION_BY}> <{$product.product_joined_manufacturers}><{/if}>div>
            <{if 
$mod_pref.use_price}><div class="oledrion_productprice"><{if $product.product_stock }><{$smarty.const._OLEDRION_PRICE}> <a href="<{$smarty.const.OLEDRION_URL}>caddy.php?op=addproduct&product_id=<{$product.product_id}>" title="<{$smarty.const._OLEDRION_ADD_TO_CART}>"><{if $product.product_discount_price_ttc != ''}><s><{$product.product_price_ttc}>s> <{$product.product_discount_price_ttc}><{else}><{$product.product_price_ttc}><{/if}> <img src="<{$smarty.const.OLEDRION_IMAGES_URL}>cartadd.png" alt="<{$smarty.const._OLEDRION_ADD_TO_CART}>" border="0" />a><{else}><{$mod_pref.nostock_msg}><{/if}>div><{/if}>
        td>
      tr>
    table>
        td>
    tr>
    <{/foreach}>
    table>
<{/if}>


thanks

2
ghia
Re: oledrion shop - display products in 3 colums
  • 2008/8/31 22:19

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I think you could try with something like this:
<{foreach item=product from=$products name="prodloop"}>
{
capture name="column"}{math equation="x % 3" x=$smarty.foreach.prodloop.index}{/capture}
{if 
$smarty.capture.column == "0"}
    <
tr>
                <
td class="oledrion_productthumb">
                td>
                <
td class="oledrion_productssummary">
                td>
{elseif  
$smarty.capture.column == "1"}
                <
td class="oledrion_productthumb">
                td>
                <
td class="oledrion_productssummary">
        td>
{elseif 
$smarty.capture.column == "2"}
                <
td class="oledrion_productthumb">
                td>
                <
td class="oledrion_productssummary">    
        td>
    tr>
table>
{/if}
{/foreach}

{if 
$smarty.capture.column == 0}
<
td>td><td>td>
{/if}

{if 
$smarty.capture.column <= 1}
<
td>td><td>td>
tr>table>
{/if}
(To show the idea I have left out the oledrion content The art of asking questions.

3
Bleekk
Re: oledrion shop - display products in 3 colums
  • 2008/8/31 23:04

  • Bleekk

  • Theme Designer

  • Posts: 941

  • Since: 2002/12/14


thank you very much ghia
it works perfekt

I have added you code but without the last lines
{if $smarty.capture.column == 0}
<
td>td><td>td>
{/if}

{if 
$smarty.capture.column <= 1}
<
td>td><td>td>
tr>table>
{/if}

for what is this?

thanks!!

4
ghia
Re: oledrion shop - display products in 3 colums
  • 2008/8/31 23:14

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


To add cells in the last row and to complete the table with the closing tag if there are not a multiple of 3 products. (See produced html source)

5
trabis
Re: oledrion shop - display products in 3 colums
  • 2008/8/31 23:17

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


HUm , very interessing code!
In this code
tr>
table>
{/if}
{/foreach}


it seems that '' should not be there.

Then you add bellow:
{if $smarty.capture.column == 2}
table>
{/if}

for example...

HUm, better yet:
tr>
{/if}
{/foreach}

{if 
$smarty.capture.column == 0}
<
td>td><td>td>
{/if}

{if 
$smarty.capture.column <= 1}
<
td>td><td>td>
tr>
{/if}

{if 
$smarty.capture.column <= 2}
table>
{/if}

6
ghia
Re: oledrion shop - display products in 3 colums
  • 2008/9/1 9:25

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
it seems that '' should not be there.
You're right, my mistake.

{if $smarty.capture.column <= 2table> {/if}
can be simply
table>
because we will close the table tag anyway at the end.

PS Now the data cells are repeated for the number of columns in the template. I believe further optimization would be possible by using the original template and switching the and tags on and off as needed as in:
{if $smarty.capture.column == "0"}
     <
tr
{/if}
 
datablock
{if $smarty.capture.column == "2"}
     tr
{/if}

This would make it more generic.

7
bprado
Re: oledrion shop - display products in 3 colums
  • 2009/1/10 19:51

  • bprado

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/9/9 1


What file do i need to change to show 3 products per row?

8
ghia
Re: oledrion shop - display products in 3 colums
  • 2009/1/10 19:58

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I think it was /modules/oledrion/templates/oledrion_allproducts.html .

9
bprado
Re: oledrion shop - display products in 3 colums
  • 2009/1/11 15:11

  • bprado

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/9/9 1


ghia you have the final code, what i have to modify or to add to show the 3 products per row?

10
ghia
Re: oledrion shop - display products in 3 colums
  • 2009/1/11 15:27

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


No, I don't!
You have to combine your original file (similar to post #1) with the code snippets and corrections from post #2, 5 and 6.

Login

Who's Online

516 user(s) are online (379 user(s) are browsing Support Forums)


Members: 0


Guests: 516


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits