Jump to content

Add a second image to category


dannyTse

Recommended Posts

By default, you can only have one image for each category in PrestaShop.
But if you really have the need to do this, it is possible.
You will need to change a little bit code change on theme file.

How t make this possible
1. Create your own additional image for each category
2. FTP to the folder YourSiteRoot/img/c
3. Rename your image to X-category-1.jpg, X-category-2.jpg,.....
Where X is the ID of category
4. Use your category image at any theme file like category.tpl

Link to comment
Share on other sites

easy man !

 

But this would be hard coded modification since prestashop published a buggy an incomplete version known as A.4 wich does not include ovveride nor tpl for the admin. So this will not be true in some close future, and we'll have to recode that. ( sometimes i'm extremly pissed with prestashop policy in terms of new versions : we've been in the same school guys, didn't you learnd anything ? )

 

So, back to the point !

Modify AdminCategories.php

replace

$this->fieldImageSettings = array('name' => 'image', 'dir' => 'c');

 

with

$this->fieldImageSettings = array();
$this->fieldImageSettings[] = array('name' => 'image', 'dir' => 'c');
$this->fieldImageSettings[] = array('name' => 'image2', 'dir' => 'c2');

 

find

'.$this->l('Image:').' 

';
	echo		 $this->displayImage($obj->id, _PS_IMG_DIR_.'c/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
	echo '	
<input type="file" name="image" />

'.$this->l('Upload category logo from your computer').'





 

add below

'.$this->l('Image:').' 

';
	echo		 $this->displayImage($obj->id, _PS_IMG_DIR_.'c2/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
	echo '	
<input type="file" name="image2" />

'.$this->l('Upload second category logo from your computer').'





 

tricky point you'll have to find out by yourself, the second image will not be deleted when deleting the category

 

don't forget to create c2 directory in img/ and let us know if you have issues with that

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi guys!

 

This topik help me with my problem to add second image to category.

I try solve from post #5, but i still need help with this.

 

After modification:

 

- if upload only second image - all fine, but after uplading first image on catogory edit page in first and second image block show only first image. Not cool to future administation.

- Deleting images - delete only first image. And if i puch to delete second image - delete first image.

 

May be you have some tips for this...

 

Thx!

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...
  • 3 months later...
  • 7 months later...

easy man !

 

But this would be hard coded modification since prestashop published a buggy an incomplete version known as A.4 wich does not include ovveride nor tpl for the admin. So this will not be true in some close future, and we'll have to recode that. ( sometimes i'm extremly pissed with prestashop policy in terms of new versions : we've been in the same school guys, didn't you learnd anything ? )

 

So, back to the point !

Modify AdminCategories.php

replace

$this->fieldImageSettings = array('name' => 'image', 'dir' => 'c');
with

$this->fieldImageSettings = array();
$this->fieldImageSettings[] = array('name' => 'image', 'dir' => 'c');
$this->fieldImageSettings[] = array('name' => 'image2', 'dir' => 'c2');
find

'.$this->l('Image:').' 
				
';
		echo		 $this->displayImage($obj->id, _PS_IMG_DIR_.'c/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
		echo '	
<input type="file" name="image" />
					
'.$this->l('Upload category logo from your computer').'
				

				

	
add below

'.$this->l('Image:').' 
				
';
		echo		 $this->displayImage($obj->id, _PS_IMG_DIR_.'c2/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
		echo '	
<input type="file" name="image2" />
					
'.$this->l('Upload second category logo from your computer').'
				

				

	
tricky point you'll have to find out by yourself, the second image will not be deleted when deleting the category

 

don't forget to create c2 directory in img/ and let us know if you have issues with that

 

Can i help you?. I need make module.

Link to comment
Share on other sites

"AdminCategories.php" is not exist in my "YouSiteRoot/YuurAdminFolder/tabs/AdminCategories.php".

How to solve/add it?

 

guide above is related to old prestashop, you probably use 1.5.x release this is why this file doesnt exist.

Link to comment
Share on other sites

  • 6 months 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...