Jump to content

[Solved] add short description to sub categories


Whispar1

Recommended Posts

Inherently, no. I'd like to see this feature added, but, from the looks of it, PrestaShop doesn't seem to offer the ability natively.

 

That said, this shouldn't be too hard to achieve. You would need to use overrides, namely AdminCategoryContoller and the Category Class. Within AdminCategoryController, you could target the __contruct method and renderForm to get the Short Description option to show while editing/creating a category. Obviously, you'd need to alter the database a bit to compensate for the new field. Assign the variable to Smarty and you should be able to call it in your template.

 

I'll try to work on the overrides sometime this week. If I get this working, I'll post the code here for you.

 

Cheers.

  • Like 2
Link to comment
Share on other sites

So the Override Installation is having an issue, so you'll need to manually drop in

 

/overrides/controllers/admin/AdminCategoriesController.php

 

And

 

/overrides/classes/Category.php

 

To their respective override folders. The rest of the install should go smoothly, though. If you have SSH access/Git installed on your server, it'd be easier to CD to your modules directory and use

 

git clone https://github.com/michaelkmartin/blockcategoryshortdesc.git

 

I plan on making changes to the module as I clean it up, so it'd be easier for you to update. Once you've cloned and installed it, you'll see a new Short Description field in the Category Form.

 

You can retrieve the data by using

 

{$category->short_description}

 

in your TPL file. That should be it, let me know if you run into any issues.

  • Like 2
Link to comment
Share on other sites

Right, the overrides will have to be uploaded manually. So the process should look like this.

 

1. Upload the blockcategoryshortdesc directory into your modules directory.

2. Log in to your Back Office and go to Modules.

3. Search for Category Short Descriptions and install the module.

4. Once installed, manually move the two override files into their respective directories in /override

 

Once all of that is done, you can go into your BackOffice and see the new field at the bottom of the category form.

 

Keep in mind, the override files probably already exist in your build. Assuming that you've never changed those files, you can simple overwrite them.

 

Good luck and feel free to send me a PM if you run into any issues. I built that out a bit quickly so I may have missed something.

  • Like 1
Link to comment
Share on other sites

@PotionsFactory

 

You can simplify Category class, like that:

 

<?php
class Category extends CategoryCore
{
public $short_description;

public function __construct($id_category = null, $id_lang = null, $id_shop = null)
{
 parent::__construct($id_category, $id_lang, $id_shop);

 self::$definition['fields']['short_description'] = array('type' => self::TYPE_HTML, 'shop' => false, 'validate' => 'isString');
}
}

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

  • 1 month later...

Since PotionsFactory was kind enough to put this together for me, I have since launched the new site.

The original module was written for the default theme and I could use a few pointers on how to implement it into the new live theme.

Any direction would be appreciated :)

Link to comment
Share on other sites

  • 3 weeks later...

Maybe a fresh set set of eyes will help :blink:

My mod to category.tpl is as follows:

 

{if $subcategory.short_description}
  <p class="cat_desc">{$subcategory.short_description}</p>
 {elseif $subcategory.description}
  <p class="cat_desc">{$subcategory.description}</p>
 {/if}

 

Both overrides are in place. What am I missing??

Link to comment
Share on other sites

  • 2 months later...

Hey guys thanks for the module provided above, works perfectly and amazing that it's free.

 

Just one question, at the same spot as Whispar1 above, if I use {$subcategory.short_description}it doesn't work but {$category->short_description}works great.

 

I'm trying to get subcategory.short_description to work in category.tpl under subcategory for each list item so I can display some content before user clicks on the category link.

 

Any ideas? Thanks again for the great solution.

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

  • 2 years later...

Hello!

 

I tried to install this plugin on Prestashop 1.6.0.1 (Automatic install and manual install).

With automatic install, Prestashop says "module installed" but I don't find the module in modules list.

 

I'm very interested by this module  :(

 

Is this plugin not ready for 1.6? @PotionsFactory, do you want to install it on my website? I'll pay you of course.

 

Regards.

Link to comment
Share on other sites

  • 7 months later...

If anyone's still interested in this module, I'll add a couple of words. Make sure you've done the following things:

1. Deleted the folder overrides/ from the module folder. 

2. Deleted the file cache/classes-index.php after copying your overrides.

3. Copied the code of the functions you override from core classes and controllers since it can be changed already. Just don't forget to replace the necessary code.

In Category.php file the necessary lines are: 

'short_description' =>  array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'), 

and 

public $short_description;

In AdminCategoriesController they are

$this->fields_form['input'][] = array('type' => 'textarea',
'label' => 'Short Description:',
'name' => 'short_description',
'lang' => true,
'rows' => 5,
'cols' => 100,   );
return AdminController::renderForm();

Actually you can add the array definition a little bit earlier if you want the field to be displayed right after the Description field.

Edited by annaoomph (see edit history)
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...