Changing products list

Hello



I’m trying to find the TPL, which displays list of products from each category. I need to rearrange certain things as per attached picture. Please advise. Thank you.

products list.jpg

The list of products is not in the tpl files. It is passed as a parameter. I.e. if you’re in a category view it loops on the products within that category.



Take a look at the controller (controllers/*) for the view you are interested in. It will generate the list there. You can probably find a hook that will allow you to interceed in the list generation. Hope that helps.

[quote name=‘tbirnseth’]The list of products is not in the tpl files. It is passed as a parameter. I.e. if you’re in a category view it loops on the products within that category.



Take a look at the controller (controllers/*) for the view you are interested in. It will generate the list there. You can probably find a hook that will allow you to interceed in the list generation. Hope that helps.[/QUOTE]

I think he is just trying to change the presentation for each product in the list. Do the controllers any presentation information?



Take a look at /skins/basic/customer/views/products/components/buy_now.tpl - It has the product block in it. However, the product block is used in both the list of products and the product details page and I have not yet figured out how to make the display conditional based on which location is being displayed.



Bob

Thank you guys for your help.



What I’m trying to achieve is to squeeze the list of available products when a category is selected. Basically, I think there’s no need for any description there. If someone is interested in reading about the product, it will be just enough to simply click on in. Same with the look of the listing - I need to present more items on the screen. At least 20 and with the default design, this will take 3 full screen scrolls to look at. all of them. By rearranging some elements, I was trying to got more room for more products.



Anyway. What is happening is I decided to go back to 1.3.5 SP4. So far, stable and reliable. There won’t be any service pack any more for the above version nor extra modules. So I can design and customise it the way I like it. If there will be any update release for 1.3.5, this would be most probably security patch. That will do the job for me. So far, I’m having trouble with 2.0.6. Can’t get the look I want, blocks are playing on me. They’re appearing then are gone for no reason. People can place fake orders and even without paying, my stock will decrease and invoice will be generated and a few more.



And I think, there will be still many updates, which will break certain things and will consume my time. I need to focus on my online business, not on CS2.??? and getting it back to work after I apply updates.



The 1.3.5 will keep me happy with all it has + mods, for another year. It does 90% of what I need. Meantime, v2 will become fully stable I hope, and glitches will be gone. I can’t spend my evenings on browsing CS forum looking for solutions. Just my 2.5 :wink: pence.



Thank you guys and I hope, CS won’t fully forget about 1.3.5 :slight_smile:


{if $controller == 'categories'}
this is a product list
[elseif $controller == 'products'}
this is a product detail page
{/if}

tbirnseth-



Thanks for the help. Now I can finish my weight display mod in this thread:

[url]http://forum.cs-cart.com/showthread.php?t=12161[/url]



Bob

Thanks EZ. Will keep it for the reference. :wink:






[quote name=‘tbirnseth’]
{if $controller == 'categories'}
this is a product list
[elseif $controller == 'products'}
this is a product detail page
{/if}
[/QUOTE]

From your description it sounds like you want to modify the data that is sent to the template by eliminating the short/long descritpions, etc. You would do this in a categories.post.php addon file where you would look at the array of products and set the fileds you don’t want to ‘’ or zero values (or simply eliminate them). Then you would do a Registry::get(‘view’)->assign(‘products’, $products); That will reset the $products array that is passed to the template.



Hope that helps.

Hi guys and EZ



I still cannot figure out how to remove the product description from product list. I still need it when customer wants to see the product in details, but not on the list. Please see the attached and advise if possible. Thank you.

prod_list_no_descr.jpg

If I’m correct, you are using 1.35. If so, no way I can help you.

No, this is regarding 2.0.6. If I can customise things, I will be switching soon.

1 way is to use more than 1 column.

Your picture indicates different than what I see in the code. What should be presented under 2.0.* is a “tabsbox” where the description is “one of the tabs” or possibly the only tab. But your image does not show any tabs, but only what looks like a block.



Hard to tell from what’s provided. What does the URL say when you go to that page?

Hi guys



Two columns it’s not an option.



What’s on the attached picture is one of the categories I have, Just a list of available products in that category, not the product itself. That’s why no tabs are there.



The URL with SEO on is:



[url]mydomain.co.uk - mydomain Resources and Information.



Thank you.

I think this is what you want. Wrap the code with the ‘if’ as shown below in /skins/YOURSKIN/customer/views/products/components/products.tpl:


[COLOR="Red"]{if $controller == 'products'}[/COLOR]
{if $product.short_description || $product.full_description}


{if $product.short_description}
{$product.short_description|unescape}
{else}
{$product.full_description|unescape|strip_tags|truncate:280:"..."}{if $product.full_description|strlen > 280}{$lang.more_link}{/if}
{/if}
[COLOR="red"]{/if}[/COLOR]




Of course, it would be best to do this with a ‘hook’ so you will not have to resolve this issue when the nest upgrade rolls out.



Bob

Bob, thank you.



Which file do I edit please?

[quote name=‘Noman’]Bob, thank you.



Which file do I edit please?[/QUOTE]



I just added it above. I realized I left it out right after I posted.



Bob

Oh Bob! Why I’m an idiot and you know everything? :wink:



This works like a charm man. And what about those “hooks”? What do I do with them and where please?



Thank you Bob and guys! I owe you some beer :wink:

[quote name=‘Noman’]This works like a charm man. And what about those “hooks”? What do I do with them and where please?[/QUOTE]



You can check out this [url]http://forum.cs-cart.com/showpost.php?p=55292&postcount=2[/url] to get a general idea of how hooks work and also a specific example (displaying the product weight on the product detail page).



You will need to install the ‘Local configuration’ add-on which is also explained in that post.



For this specific change, you will find the following hook in /skins/YOURSKIN/customer/views/products/components/products.tpl:

{hook name="products:product_block"}



We will need to create a hooked file in /skins/YOURSKIN/customer/addons/local/hooks/products (you might need to create the directory ‘products’). The file we will create will be named product_block.override.tpl (product_block is specified in the {hook name="products:[COLOR=“Red”]product_block[/COLOR]) and override since we need to substitute our code for the normal code in /skins/YOURSKIN/customer/views/products/components/products.tpl.



Here are the steps:


  1. Open /skins/YOURSKIN/customer/views/products/components/products.tpl;
  2. Copy the lines between the {hook name=“products:product_block”} and the closing {/hook} - lines 15-36:

```php {assign var=“obj_id” value=“$obj_prefix``$product.product_id”}




{if $item_number == "Y"}{$smarty.foreach.products.iteration}. {/if}{$product.product|unescape}

{include file="views/products/components/buy_now.tpl" product=$product but_role="action" show_features=true show_sku=true hide_add_to_cart_button=$hide_add_to_cart_button}

{if $product.short_description || $product.full_description}

{if $product.short_description}
{$product.short_description|unescape}
{else}
{$product.full_description|unescape|strip_tags|truncate:280:"..."}{if $product.full_description|strlen > 280}{$lang.more_link}{/if}
{/if}

{/if}

```
3) Paste the copied code into a text editor;
4) Add the bits in red:
```php {include file="views/products/components/buy_now.tpl" product=$product but_role="action" show_features=true show_sku=true hide_add_to_cart_button=$hide_add_to_cart_button}

[COLOR="Red"]{if $controller == 'products'} [/COLOR]
{if $product.short_description || $product.full_description}

{if $product.short_description}
{$product.short_description|unescape}
{else}
{$product.full_description|unescape|strip_tags|truncate:280:"..."}{if $product.full_description|strlen > 280}{$lang.more_link}{/if}
{/if}
[COLOR="Red"]{/if}[/COLOR]
```
5) Save the file as product_block.override.tpl;
6) Use your FTP client to create the products directory in /skins/YOURSKIN/customer/addons/local/hooks if it does not exist;
7) Copy product_block.override.tpl to /skins/YOURSKIN/customer/addons/local/hooks/products on your server;
8) Make sure permissions are set appropriately for the products directory and product_block.override.tpl (usually 755);
9) Clear your template cache ([url]http://www.YOURDOMAIN.com/admin.php?dispatch=categories.manage&cc[/url])

This may seem the long way round to achieve the same result but using this method will get your store up and running faster after each and every upgrade.

Bob

Bob and other gentlemen, I thank you very much for your effort. This helps me a lot. Great support, great product and the best people here at forum.



I will check that solution once again when back at home and will let you know. Thanks once again Bob!