Jump to content

add description under subcategories


Recommended Posts

Hello,
When we click 1 category, it appears the subcategories arranged in column with for each a photo and the title of this subcategory.

I would like to add under the title of every subcategory 2 or 3 additional descriptions. (center blok)

I think that it is already necessary to create a new table,and add fields in the page addition of a subcategory ( BO).

Could you say me about it a little more to help me to realize this modification.

Thank you for your help.

Jym

Link to comment
Share on other sites

It would be easier if you just put those two or three descriptions into the subcategory description. That way, you don't have to modify the database. Would you be happy with that? You could then do the following modification.

It is the following code starting on line 23 of category.tpl in your theme's directory that displays the subcategories in the centre column:

   {if isset($subcategories)}
   <!-- Subcategories -->

{l s='Subcategories'}

       {foreach from=$subcategories item=subcategory}

               <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
                       <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
                   {else}
                       <img src="{$img_cat_dir}default-medium.jpg" alt="" />
                   {/if}
               </a>


               <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}

       {/foreach}




   {/if}



I suggest adding the following after line 38 (before the ):



{$subcategory.description|truncate:50}



This will display the subcategory description to truncate it so no more than 50 characters are displayed. You can adjust that number until the description appears as you like.

By default, the subcategories do not have a fixed width, so this may end up looking messy. I suggest that you make them fixed-width by changing the following code in the /* category.tpl */ section of global.css in your theme's directory to:

body#category #subcategories li {
   margin-right:10px;
   width: 100px;
}



Change the width from 100px to whatever width of the subcategory columns you are happy with.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

Thank you for your solution, but i would like to add an other field too.

So i think i have to create a new table, edit the "add category page" in the BO and add {$subcategory.description001|truncate:50} in category.tpl

But i don t know how to edit the category page in the BO.

Thank you

Link to comment
Share on other sites

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...