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`&slot=`$ slot`"} {else} {assign var="url" value="product.php?productid=`$product.productid`& amp;cat=`$cat`&page=`$navigation_page`"} {if $featured eq 'Y'} {assign var="url" value=$url|cat:"&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&cat=&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&cat=&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&cat=&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&cat=&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&cat=&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! |
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. |
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? |
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?
|
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? |
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> 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. |
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?
|
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? |
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} Right below that you can see it defining a foreach loop Code:
{foreach from=$products_matrix item=row name=products_matrix} Then we see: Code:
{foreach from=$row item=product name=products} 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. :) |
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? |
All times are GMT -8. The time now is 08:01 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.