Jump to content

[SOLVED] Modify the layout of subcategories


Recommended Posts

Hello Folks!

I wonder if it possible (and how) to display subcategories of a parent category like the list of products in a category (of course without price info etc) and with the related text set for the subcategory.

Any help is really appreciated.
Paolo

Link to comment
Share on other sites

  • 2 weeks later...

I opened the file mytheme/category.tpl and modified the HMTL content of the foreach loop this way:

>
       {foreach from=$subcategories item=subcategory}

</pre>
<table width="500" style="margin-left:20px;margin-bottom:10px;border:1px solid;" border="0" cellspacing="2" cellpadding="2">
getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
                   {else}

                   {/if}

                
                   <!-- COLLEGAMENTO SOTTOCATEGORIA -->                
getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}
                
{$subcategory.description}                
</table>
<br><br>       {/foreach



It's just what I did for my site but can be done in 1000 different ways provided someone know a bit of coding.

The result is attached.

22156_4cGDhf9ZMGqsRBUXuTsK_t

Link to comment
Share on other sites

  • 4 months later...

I was looking for the same thing and stumbled across this post.
The code provided by tempomania grabs subcat descriptions and displays it in parent category. Shouldnt this result in duplicate content?

Is there a module which adds category short description, same as products?

To answer my question:
i simply added extra field in 'ps_category_lang' named 'shortdescription'
added few lines to classes/category.php
put this in category.tpl {$subcategory.shortdescription} and it works!

Prestashop is way too easy to modify for someone with 0 coding experience!

Link to comment
Share on other sites

  • 4 weeks later...
>{foreach from=$subcategories item=subcategory}

</pre>
<table width="510" style="margin-left:10px;margin-bottom:10px;border:1px solid;" border="0" cellspacing="2" cellpadding="2">    
0}class="no-bg"{/if}>

               {if $subcategory.id_image>0}
getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />

               {/if}

              
getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}"></table>
<br>       {/fo

Link to comment
Share on other sites

  • 5 months later...

Folks I desperately try to modify my 1.3.6 subcategories and I only managed to sort them by changing the lenght of the text wrapping to subcategory level - this helps a bit but it is still far away from the nice sort that tempomania achieved in his image shown above.

When I try to make the changes mentioned here I get the table right but instead of a subcategory picture I get this "getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}"> followed by the Subcategory name!
Do you know what can be the problem?

Link to comment
Share on other sites

Ok this is the code for 1.3.6
Change the whole code from {foreach .... till {/foreach}

>{foreach from=$subcategories item=subcategory}

</pre>
<table width="510" style="margin-left:10px;margin-bottom:10px;border:1px solid;" border="0" cellspacing="2" cellpadding="2">    
0}class="no-bg"{/if}>


getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
                   {else}


                   {/if}

    </table>
<a rel="">getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
{$subcategory.name|escape:'htmlall':'UTF-8'}</a><br><br><div>{$subcategory.description}</div>  <br><br><br><br><br><br><br><br><br><br><br>       {/fo

Link to comment
Share on other sites

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...