Jump to content

[SOLVED] Display sub categories as grid


Recommended Posts

Hi,

 

is it possible to display sub categories in a grid format? At the moment I cannot seem to figure out how to do this.

 

 

Any help with this would be appreciated,

 

Thank you :)

 

EDIT:

 

Just to add, is it normal that sub categories are not displayed? I only have the default products in prestaShop (1.5.4.1) but when a top level category is selected it will simply show all products of all categories, without showing any sub categories.

Edited by RCP90 (see edit history)
Link to comment
Share on other sites

Hi,

 

is it possible to display sub categories in a grid format? At the moment I cannot seem to figure out how to do this.

 

something similar to this:

 

 

http://www.toolstop..../hand-tools-b60

 

Any help with this would be appreciated,

 

Thank you :)

 

 

Grid subcategories: http://victor-rodena...prestashop-1-5/ (In Spanish) (Sorry)

 

Grid product by categories: http://nemops.com/gr...prestashop-1-5/

 

Sorry for my English

  • Like 1
Link to comment
Share on other sites

Nadie,

 

Thank you for your reply, I shall take a look at this, i will let you know the results :)

 

Although, strangely i am not getting any sub categories to display not even in a list. I have the default out of the box products, and have placed some of them 3 category levels deep, however when the top level category is click it will just show all of the products directly, as though ti has skipped all of the categories.

Edited by RCP90 (see edit history)
Link to comment
Share on other sites

 

Although, strangely i am not getting any sub categories to display not even in a list. I have the default out of the box products, and have placed some of them 3 category levels deep, however when the top level category is click it will just show all of the products directly, as though ti has skipped all of the categories.

 

¿Use template default Prestashop or no?

 

Sorry for my English

Link to comment
Share on other sites

Hello,

 

I am using this theme

 

http://themeforest.n...preview/3178575

 

 

:)

 

In category.tpl,

 

 

Check to see if you have this code:

 

{if isset($subcategories)}
 <!-- Subcategories -->
 <div id="subcategories">
  <h3>{l s='Subcategories'}</h3>
  <ul class="inline_list">
  {foreach from=$subcategories item=subcategory}
   <li class="clearfix">
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}" class="img">
  {if $subcategory.id_image}
   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {else}
   <img src="{$img_cat_dir}default-medium_default.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {/if}
 </a>
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
 {if $subcategory.description}
  <p class="cat_desc">{$subcategory.description}</p>
 {/if}
   </li>
  {/foreach}
  </ul>
  <br class="clear"/>
 </div>
 {/if}

Link to comment
Share on other sites

Hello,

 

Thank you again for the reply, I could find this;

 

   {if isset($warehouse_vars.show_subcategories) && $warehouse_vars.show_subcategories == 1}
		  {if isset($subcategories)}
 <!-- Subcategories -->
 <div id="subcategories">
  <h3>{l s='Subcategories'}</h3>
		    <script type="text/javascript" >
$(window).load(function() {
   setHeight2('.grid_list_categories li');
});

</script>
  <ul class="grid_list_categories clearfix">
  {foreach from=$subcategories item=subcategory}
   <li>
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}" class="img">
  {if $subcategory.id_image}
   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')}" alt="" />
  {else}
   <img src="{$img_cat_dir}default-medium_default.jpg" alt=""   />
  {/if}
 </a>
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'|truncate:42:'...'}</a>

   </li>
  {/foreach}
  </ul>
  <br class="clear"/>
 </div>
 {/if}{/if}

Link to comment
Share on other sites

Hi,

 

Just to clarify something. My sub categories are appearing on the left hand side of the site. What i want is to have them in the middle of the page, in a grid format so that the user can navigate though them, to the product they require.

 

currently even if a top level category is selected every product form all sub categories are being displayed, with the sub categories being displayed on the left hand side, acting more like a filter.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
  • 2 weeks later...
  • 2 months later...

I just changed

 

.inline_list li .img {

display: block;
margin-left: auto;
margin-right: auto
margin-top: 15px;
}
 
 
to 
.inline_list li .img {
display: block;
margin-left: auto;
margin-right: auto
margin-top: auto;
}
 
GueMolo.png
but it still doesn't look good. What do i do to remove that dotted margin(or make it clear) and how do i make it display category names if they have longer names? As you can see in category #2
Edited by SeVi (see edit history)
Link to comment
Share on other sites

  • 2 months later...

Hi,

 

I've tried all the suggestions above and still cannot seem to get my grid view to look right. At present it looks like this:

 

9PdGnRZ.png

 

I want the image to be centred and the grid boxes to be slightly taller.

 

The code I currently have is:

 

.inline_list {
list-style-type:none;
margin-top:5px;
}
 
.inline_list  li {
text-align: center;
float: left;
display: inline-block;
width: 96px;
height: 125px;
margin: 5px;
}
 
.inline_list  li .img {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: auto;
}
 
.inline_list  li img {
border:1px solid #ccc
}
 
.inline_list  li .cat_name {
font-size:12px
}
 
Any help is much appreciated,
 
Many Thanks
Link to comment
Share on other sites

  • 4 weeks later...

remove float:left; from:

.inline_list li .img {
display: block;
float: left;
margin-top: 15px;
}

also, if i were you i will increase height param in:

.inline_list li {
text-align: center;
float: left;
display: inline-block;
width: 96px;
height: 100px;
border: 1px dotted #ccc;
margin: 4px;
}

for example, use 120px;

 

 

effect:
JHOXc2o.png

  • Like 1
Link to comment
Share on other sites

Hey thanks Vekia for your reply.

I had changed float left to float center and that worked but have now just removed it as per yr advice. Have increased height to 100 and it looks good.

 

However for some reason on my home page the featured products some of the image blocks are stuck together, please could you tell me what to change?

 

Kind Regards,

Lee


sorry www.gr8-kitchenware.co.uk

Link to comment
Share on other sites

it's not related to this topic but i will help,

in the future please create new threads to questions not related to main case in topic, where you post.

 

ok, so, open homefeatured.tpl file

there is a code:

{assign var='nbItemsPerLine' value=4}

 

change it to:

{assign var='nbItemsPerLine' value=5}

Link to comment
Share on other sites

  • 4 weeks later...

Hello Vekia,

 

I have also adapted my template to this grid categorieview. Managed to enlarge it a bit. Beautifull!

But since I've done that, 'featured products' at my homepage doesn't fit.

 

Could have also been from changing preferences/images home_default size to 140px??

(I did so for the grid/list/minilist product layout)

 

Please help.

 

PS 1.5.6.2

shop.lrpartners.nl

Link to comment
Share on other sites

Thanks, home featured is ok now.

 

 

By changing the size from medium_default back to 56 x 56px (from 100x100), I also changed the image size of my subcategories (grid-view).

Could I seperate these 2 in some way?

Maybe by creating a new image (preferences/images/...) and referring it to the subcategory in code?

 

 

Same for my products (grid_view). By changing the home_default images size back to 124 x 124px (from 140x140), my products images within categories became smaller.

Link to comment
Share on other sites

you can do it,

just create new imagetype for your categories.

you can do it under preferences > images tab. 

Create new image, for example, named "category_image"

use it only for categories.

 

Then in category.tpl change medium_default to category_image (for subcategories)

 

voila ;)

  • Like 1
Link to comment
Share on other sites

I have tried but it had no effect. Example: http://shop.lrpartners.nl/nl/40-mannen

No cache, compilation forced and all images are regenerated.

 

 

This is the code in witch I changed it, name of image is "category_thumb" (100x100px):

{if $subcategory.id_image}
                            <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'category_thumb')|escape:'html'}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
                        {else}
                            <img src="{$img_cat_dir}default-category_thumb.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
                        {/if}

 

=> also tried without removing the last "home_default"(.jpg)

 

In product-list.tpl: (for product listing within category => new image: "catprodview"; 124x124px)

  <div class="center_block">
                <a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}">
                    {if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="on_sale">{l s='On sale!'}</span>{/if}
                    <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'catprodview')|escape:'html'}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />
                    {if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}
                </a>

 

 

I missed something in the PrestaShop back office?

 

Many thanks! ^_^

Link to comment
Share on other sites

you changed images for products to catprodview

you created this imagetype a nd marked it as image for products?

in addition, it's necessary to regenerate thumbnails, you did that?

 

Yes I have:

preferences_images.PNG

 

After having no succes regenerating this particular image sizen in products & categories, I regenerated (multiple times) without result.

 

Allthough I'm new at this, it looks like a logic peace of code. I have no idea why it is not having its effect.

 

Can it help if I provide you with a superadmin login in private message?

Link to comment
Share on other sites

They appear exactly the same as before, no change.

 

Here I see the subcategory images at 56x56px, while they should be 100x100px,

and here I see the subcategory images at 124x124px, while it should be 140x140px. (they are slightly smaller and to the left)

 

I can't send you private message, so I've send you a friend request to share the login info.

 

Thanks many, many times! A true PrestaShop Legend you are!

Link to comment
Share on other sites

done you can send me private messages now   :)

 

I have tried a few times more with different names and sizes. Still no result.

The image previously referred to as 'catprodviews' is now called 'product_layout'.

 

I've send you some credentials in PM. Thanks again!

Link to comment
Share on other sites

×
×
  • Create New...