Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

help with products_list.tpl problem, repeating product?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-26-2011, 11:36 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default help with products_list.tpl problem, repeating product?

My current tpl looks like this;


{*
$Id: products_list.tpl,v 1.4.2.5 2010/12/15 11:57:05 aim Exp $
vim: set ts=2 sw=2 sts=2 et:
*}


<div class="products products-list">
{foreach from=$products item=product name=products}

<script type="text/javascript">
//<![CDATA[
products_data[{$product.productid}] = {ldelim}{rdelim};
//]]>
</script>

{if $active_modules.Product_Configurator and $is_pconf and $current_product}
{assign var="url" value="product.php?productid=`$product.productid`& amp;pconf=`$current_product.productid`&amp;slot=`$ slot`"}
{else}
{assign var="url" value="product.php?productid=`$product.productid`& amp;cat=`$cat`&amp;page=`$navigation_page`"}
{if $featured eq 'Y'}
{assign var="url" value=$url|cat:"&amp;featured=Y"}
{/if}
{/if}

<div{interline name=products additional_class=item}>

<div class="image"{if $config.Appearance.thumbnail_width gt 0 or $product.tmbn_x gt 0} style="width: {$max_images_width|default:$config.Appearance.thum bnail_width|default:$product.tmbn_x}px;"{/if}>
<a href="{$url}">{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.tmbn_x image_y=$product.tmbn_y product=$product.product tmbn_url=$product.tmbn_url}</a>

{if $active_modules.Special_Offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl"}
{/if}
<a href="{$url}" class="see-details">{$lng.lbl_see_details}</a>

{if $active_modules.Feature_Comparison}
{include file="modules/Feature_Comparison/compare_checkbox.tpl"}
{/if}

</div>
<div class="details"{if $config.Appearance.thumbnail_width gt 0 or $product.tmbn_x gt 0} style="margin-left: {$max_images_width|default:$config.Appearance.thum bnail_width|default:$product.tmbn_x}px;"{/if}>

<a href="{$url}" class="product-title">{$product.product|amp}</a>










<tr>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>

</tr>











{if $config.Appearance.display_productcode_in_list eq "Y" and $product.productcode ne ""}
<div class="sku">{$lng.lbl_sku}: <span class="sku-value">{$product.productcode|escape}</span></div>
{/if}

<div class="descr">{$product.descr|amp}</div>

{if $product.rating_data}
{include file="modules/Customer_Reviews/vote_bar.tpl" rating=$product.rating_data productid=$product.productid}
{/if}

<hr />

{if $product.product_type eq "C"}

{include file="customer/buttons/details.tpl" href=$url}

{else}

{if $active_modules.Subscriptions ne "" and ($product.catalogprice gt 0 or $product.sub_priceplan gt 0)}

{include file="modules/Subscriptions/subscription_info_inlist.tpl"}

{else}

{if not $product.appearance.is_auction}

{if $product.appearance.has_price}

<div class="price-row{if $active_modules.Special_Offers ne "" and $product.use_special_price ne ""} special-price-row{/if}">
<span class="price">{$lng.lbl_our_price}:</span> <span class="price-value">{currency value=$product.taxed_price}</span>
<span class="market-price">{alter_currency value=$product.taxed_price}</span>
</div>

{if $product.appearance.has_market_price and $product.appearance.market_price_discount gt 0}
<div class="market-price">
{$lng.lbl_market_price}: <span class="market-price-value">{currency value=$product.list_price}</span>

{if $product.appearance.market_price_discount gt 0}
{if $config.General.alter_currency_symbol ne ""}, {/if}
<span class="price-save">{$lng.lbl_save_price} {$product.appearance.market_price_discount}%</span>
{/if}

</div>
{/if}

{if $product.taxes}
<div class="taxes">
{include file="customer/main/taxed_price.tpl" taxes=$product.taxes is_subtax=true}
</div>
{/if}

{/if}

{if $active_modules.Special_Offers ne "" and $product.use_special_price ne ""}
{include file="modules/Special_Offers/customer/product_special_price.tpl"}
{/if}

{else}

<span class="price">{$lng.lbl_enter_your_price}</span><br />
{$lng.lbl_enter_your_price_note}

{/if}

{/if}

{if $active_modules.Product_Configurator and $is_pconf and $current_product}
{include file="modules/Product_Configurator/pconf_add_form.tpl"}
{elseif $product.appearance.buy_now_enabled and $product.product_type ne "C"}
{if $login ne ""}
{include_cache file="customer/main/buy_now.tpl" product=$product cat=$cat featured=$featured is_matrix_view=$is_matrix_view login="1" smarty_get_cat=$smarty.get.cat smarty_get_page=$smarty.get.page smarty_get_quantity=$smarty.get.quantity}
{else}
{include_cache file="customer/main/buy_now.tpl" product=$product cat=$cat featured=$featured is_matrix_view=$is_matrix_view login="" smarty_get_cat=$smarty.get.cat smarty_get_page=$smarty.get.page smarty_get_quantity=$smarty.get.quantity}
{/if}
{/if}

{/if}

</div>

<div class="clearing"></div>
</div>

{/foreach}

</div>











and, it's creating an output like this;



<tr>

<td class="PrinterDescriptionText" style="border-width:0px;"><a href="product.php?productid=12&amp;cat=&amp;page=1">LC-57BK</a><br/><img src="http://5dollarinkcartridges.com.au/newsite/image.php?id=12" width="75"></td>

<td class="PrinterDescriptionText" style="border-width:0px;"><a href="product.php?productid=12&amp;cat=&amp;page=1">LC-57BK</a><br/><img src="http://5dollarinkcartridges.com.au/newsite/image.php?id=12" width="75"></td>

<td class="PrinterDescriptionText" style="border-width:0px;"><a href="product.php?productid=12&amp;cat=&amp;page=1">LC-57BK</a><br/><img src="http://5dollarinkcartridges.com.au/newsite/image.php?id=12" width="75"></td>

<td class="PrinterDescriptionText" style="border-width:0px;"><a href="product.php?productid=12&amp;cat=&amp;page=1">LC-57BK</a><br/><img src="http://5dollarinkcartridges.com.au/newsite/image.php?id=12" width="75"></td>

<td class="PrinterDescriptionText" style="border-width:0px;"><a href="product.php?productid=12&amp;cat=&amp;page=1">LC-57BK</a><br/><img src="http://5dollarinkcartridges.com.au/newsite/image.php?id=12" width="75"></td>

</tr>




instead of using a new product, product image, and product code, etc, it's repeating the same one 6 times, and then starting on another product. how can i use 6 different products inside 1 row??!!

please help!
__________________
Version 4.4.3
Reply With Quote
  #2  
Old 09-27-2011, 04:48 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: help with products_list.tpl problem, repeating product?

We got this. Go to Settings->General Settings->Appearance

Look for:
Number of columns to display the product list in and chabge this value to 6. Now go fix your product_list.tpl back to default.

The code you posted above, is based on a{foreach} loop that is looping through the product array.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 09-27-2011, 12:43 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default Re: help with products_list.tpl problem, repeating product?

Ok, I've done that, and it completely messes up my site's design.

How would I go about editing my template file, so it ONLY shows;

<tr>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>
<td class="PrinterDescriptionText" style="border-width:0px;"><a href="{$url}">{$product.productcode|escape}</a><br/><img src="{$http_location}/image.php?id={$product.productid}" width="75"></td>

</tr>




and does this for every new 6 sets of products? I just want the image, product code, and product URL shown. How would I go about achieving this?
__________________
Version 4.4.3
Reply With Quote
  #4  
Old 09-27-2011, 01:11 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default Re: help with products_list.tpl problem, repeating product?

I reverted all my files back to original. How do I go about accomplishing what I am trying to do?
__________________
Version 4.4.3
Reply With Quote
  #5  
Old 09-27-2011, 01:22 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default Re: help with products_list.tpl problem, repeating product?

You can see my edits here; http://5dollarinkcartridges.com.au/newsite/manufacturers.php?manufacturerid=3


It's running off the page becaue the products list is so big. I just want product code, image, and link in a table format. I've already pasted the code I want to use, as well. How do I go about this?
__________________
Version 4.4.3
Reply With Quote
  #6  
Old 09-27-2011, 01:55 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: help with products_list.tpl problem, repeating product?

What you are asking for is not easy, the question seems simple, but the answer might take pages of text to explain to someone new. Let me try to shed some light on why what you did didn't work, and that should help you figure out how to make it work.

See this:
{foreach from=$products item=product name=products}--starts an array loop through the items.

So anything called inside this like {$product.productcode|escape} will spit out the current product code for this iteration of the loop.

{/foreach}--Ends the loop.

So to do what you want (This is an example not actual code)
Code:
<tr> {foreach from=$products item=product name=products} <td>{$product.productcode|escape}</td> {/foreach} </tr>

The problem with this mindset, is it doesn't allow for starting another row. What if you had 10 products, or 100?

What I directed you to before "Number of columns to display the product list" should activate a template called products_t.tpl. take a look at this to see how a properly formatted table with multiple columns is handled.

I think you are only struggling with this due to template customizations.

Perhaps you should switch templates back to a default one, just to observe the behavior of multi-column formatting of products, as controlled by the number of columns setting in the admin. I don't think any designer should have interfered with this basic functionality when building the template.

I know this probably raises more questions than it answers...but hopefully some of it makes sense.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #7  
Old 09-27-2011, 02:01 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default Re: help with products_list.tpl problem, repeating product?

So, which file do I need to edit to accomplish what I am trying to do? Only products_t.tpl?
__________________
Version 4.4.3
Reply With Quote
  #8  
Old 09-27-2011, 02:10 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default Re: help with products_list.tpl problem, repeating product?

I searched for "
foreach from=$products item=product name=products" on products_t.tpl, and I could not find that code. I could only find it on products_list.tpl?
__________________
Version 4.4.3
Reply With Quote
  #9  
Old 09-27-2011, 02:34 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: help with products_list.tpl problem, repeating product?

Cool lets look at that file and disect it starting from the top.
Code:
{list2matrix assign="products_matrix" assign_width="cell_width" list=$products row_length=$config.Appearance.products_per_row}
First it is generating a matrix and assigning the products list. This is creaing a higher level of array than the typical array you would get from $products. See that row_length attribute? That is pulling the value from the DB that you select in the field I keep pointing you to. In fact you could just hard code that number here replace $config.Appearance.products_per_row with your number of columns. (but it would be better to just leave it configurable via general settings)

Right below that you can see it defining a foreach loop
Code:
{foreach from=$products_matrix item=row name=products_matrix}
This loop will create each row of the typical product table. See the <tr> right below it.

Then we see:
Code:
{foreach from=$row item=product name=products}
This is defining each cell of the table, see the <td> and </td>

Now look down the code, you will see the 2nd foreach statement is closing. {/foreach}

This entire first foreach statement simply displays the product codes, so for your intents and purposes you could remove it completely. The next foreach finally has some meat in it, the product thumbnails and links. They are called from customer/main/program_thumbnail.tpl with an include statement.

Of course I could go on, but hopefully you are seeing the pattern. It is not madness, it does make sense after you understand the concepts.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #10  
Old 09-27-2011, 03:19 PM
 
plnewton plnewton is offline
 

Advanced Member
  
Join Date: Sep 2011
Posts: 65
 

Default Re: help with products_list.tpl problem, repeating product?

Inside products_t.tpl, I did this;


{foreach from=$row item=product name=products}
{if $product}

<td{interline name=products additional_class="product-cell"} style="width: {$cell_width}%;">
<script type="text/javascript">
//<![CDATA[
products_data[{$product.productid}] = {ldelim}{rdelim};
//]]>
</script>
<a href="{$product.alt_url|default:$product.page_url| amp}" class="product-title">{$product.productcode|escape}</a>
</td>

{/if}
{/foreach}



and, it's not seeming to show the product code for some reason?
__________________
Version 4.4.3
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:18 AM.

   

 
X-Cart forums © 2001-2020