thunder11 Posted November 1, 2009 Share Posted November 1, 2009 Hello everyone,I'm having major problems with my subcategories actually with Books category that have like 15 subcategories. When I click on Books category it list me with a list of subcategories like : Drama, Novel, History etc. And it should right. The problem is that I need like 15 subcategory pictures for it and when I put all the pcitures needed it look chaotic. I was wondering if it is possible to implement a feature that would display random books in the middle of the page instead of list of subcategories like it does now when I click on Books. Thanks. Link to comment Share on other sites More sharing options...
rocky Posted November 1, 2009 Share Posted November 1, 2009 Have you had a look at the module here? It is a modified version of the featured products that has the option to display random featured products. Link to comment Share on other sites More sharing options...
thunder11 Posted November 1, 2009 Author Share Posted November 1, 2009 Thanks Rocky,do not want to be rude, but this one didnt helped me because I already have what I want on a home page. Problem is in subcategories. You know when you click on main category you get a list of subcategories with descriptions a pictures. My main category is Books, and have like 15 subcategories under Books category. What I want is to get rid of the subcategory pictures and instead of it put a random display of products in Book category. When a buyer wants to buy a Crime Book he should navigate to that subcategory trough category block on the left. Subcategory pictures are good idea if you have 2 or 3 subcategories under main category but having more than 5 become quite confusing and finding suitable pictures for subcategories can be quite a task and yet not to have visual effect that is required from a professional looking store. Thank you very much for your support Rocky. Its not a first time you helped me Link to comment Share on other sites More sharing options...
thund3rb1rd Posted November 1, 2009 Share Posted November 1, 2009 this doesn't give you random products, but it will get rid of the images while keeping the links to the subcategoriesin prestashop/themes//category.tplremove or comment out lines 27-34make a backup of the file and try this out and see if it is suitableI don't have make subcategories in my shop to see what it looks likeif you want to get rid of the image and link all togetherremove or comment out lines 20-41 Link to comment Share on other sites More sharing options...
thunder11 Posted November 1, 2009 Author Share Posted November 1, 2009 Thank you very much Thunder. This one successfully removed subcategory pictures. The one thats left is how to manage and put random products . Hopefully Rocky will have some idea too. I think. thunder11 Link to comment Share on other sites More sharing options...
rocky Posted November 2, 2009 Share Posted November 2, 2009 I'm still not sure that I fully understand you. Do you want to display a few random products above the listings where the subcategories usually are? You can do this by adding the following code to category.php after line 59 ($cat_products = ...): $random_products = $category->getProducts(intval($cookie->id_lang), 1, 1000, $orderBy, $orderWay, false, true, true, 4); This code chooses 4 random products from the current category. You can then pass the random products into category.tpl: $smarty->assign(array( 'random_products' => (isset($random_products) AND $random_products) ? $random_products : NULL, 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name) )); Then you can change the <!-- Subcategories --> section of category.tpl in your theme's directory to: <!-- Subcategories --> {l s='Random Products'} {foreach from=$random_products item=random_product} <a href="{$link->getProductLink($random_product.id_product, $random_product.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$random_product.name|escape:'htmlall':'UTF-8'}"> {if $random_product.id_image} <img src="{$link->getImageLink($random_product.link_rewrite, $random_product.id_image, 'medium')}" alt="" /> {else} <img src="{$img_prod_dir}default-medium.jpg" alt=""> {/if} <a href="{$link->getProductLink($random_product.id_product, $random_product.link_rewrite)|escape:'htmlall':'UTF-8'}">{$random_product.name|truncate:25|escape:'htmlall':'UTF-8'} {/foreach} Sorry if this isn't what you want. It is hard for me to help when I don't understand exactly what is wanted. Link to comment Share on other sites More sharing options...
thunder11 Posted November 2, 2009 Author Share Posted November 2, 2009 Rocky you did it again. Thats what I wanted. You understood me perfectly and we are almost there. One more line of code and it will be perfect. As you know I have Main Category Books and I have the following subcategories : Crime Novels, Philosophy, History etc. Since Main Category Books doesn't have any listed books is it possible to pull random products from Crime Novels, Philosophy and History from those subcategories to be listed when a customer click on Books. Basically is it possible to get subcategory products to be listed in the parent category. As you put it only products from the current category is listed.Example Books --> Crime --> Agatha Christie : Now Agatha Christie subcategory has 3 books and I want them to be displayed once in a while when a customer click on Books or Crime. Is this possible?Thank you. Link to comment Share on other sites More sharing options...
rocky Posted November 2, 2009 Share Posted November 2, 2009 Here's what I've come up with. Change line 418 of classes/Category.php from: WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' to: LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = p.`id_category_default`) WHERE '.($random ? 'c.`id_parent` = '.intval($this->id):'cp.`id_category` = '.intval($this->id)).($active ? ' AND p.`active` = 1' : '').' and on line 406, change SELECT to SELECT DISTINCT Link to comment Share on other sites More sharing options...
thunder11 Posted November 2, 2009 Author Share Posted November 2, 2009 Almost there Rocky. Right now your work is pulling the products from the first subcategory ie. Crime subcategory pulls out products from Agatha and Connan Doyle but Books (main category) doesn't pull out anything. Many thanks. Link to comment Share on other sites More sharing options...
rocky Posted November 2, 2009 Share Posted November 2, 2009 Try this instead: LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.`id_category` = p.`id_category_default`) WHERE cp.`id_category` = '.intval($this->id).($random ? ' OR c.`id_parent` = '.intval($this->id):'').($active ? ' AND p.`active` = 1' : '').' Link to comment Share on other sites More sharing options...
thunder11 Posted November 2, 2009 Author Share Posted November 2, 2009 Got a blank page. Link to comment Share on other sites More sharing options...
rocky Posted November 2, 2009 Share Posted November 2, 2009 Sorry, it was a typo. It is getting late here and I've been coding all day. I've updated the above code. Link to comment Share on other sites More sharing options...
thunder11 Posted November 2, 2009 Author Share Posted November 2, 2009 It still pulls out from a first subcategory. I don't want to bother you any more today. Talk to you when you get some rest. Perhaps I will digg something out on my own. Many thanks Link to comment Share on other sites More sharing options...
thunder11 Posted November 2, 2009 Author Share Posted November 2, 2009 Turns out. It is doing what it suppose to. I will test it further more and let you know whats going on. thunder11 Link to comment Share on other sites More sharing options...
thunder11 Posted November 2, 2009 Author Share Posted November 2, 2009 This one is still pulling from a first subcategory. Can you make it go deeper? Thank you. Link to comment Share on other sites More sharing options...
rocky Posted November 3, 2009 Share Posted November 3, 2009 That will be more difficult, since it would require recursion. I'll see what I can do.You might be interested in this post if you want to display the book names on multiple lines instead of using .... Link to comment Share on other sites More sharing options...
thunder11 Posted November 3, 2009 Author Share Posted November 3, 2009 thanks Rocky. This problem turns out to be more difficult than I anticipated. I really respect other peoples time and work so do it when you can and I will be here. Thanks for coding my shop. Take care thunder11 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now