Subcategory Thumbnail

Phoca Cart - complex e-commerce extension
Invictus
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 24 Mar 2016, 04:19

Subcategory Thumbnail

Post by Invictus »

Hi,
How can I make my subcategories like my category page with thumbnails and view category button ?

Ty in advance
Dimitar
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47821
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Subcategory Thumbnail

Post by Jan »

Hi, sorry, I don't understand, subcategories have the same view like categories - the only one difference is that the back (up) button goes to parent category not to categories view :idea:

Jan
If you find Phoca extensions useful, please support the project
Invictus
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 24 Mar 2016, 04:19

Re: Subcategory Thumbnail

Post by Invictus »

Hi , thank you for your response ,the problemis this - in my prime category view is good you can see in the picture

Image
http://imgur.com/0ZgcUcy

but when i go to subcategories ,it is like this

Image
http://imgur.com/so15gUw

all categories and subcaterogies are made the same , and all of them have image

Ty
Dimitar
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47821
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Subcategory Thumbnail

Post by Jan »

Hi, there is categories view - which display categories - when you go to category view, subcategories displayed here are not displayed in the category view like categories in categories view. This needs to be customized :idea:

Jan
If you find Phoca extensions useful, please support the project
wildbiker
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 21 Feb 2018, 16:09

Re: Subcategory Thumbnail

Post by wildbiker »

Hi!

I have same problem, how can i customize?

Thanks!
sergiotimoff
Phoca Member
Phoca Member
Posts: 10
Joined: 25 May 2017, 17:18

Re: Subcategory Thumbnail

Post by sergiotimoff »

Hi. I have the same problem. How can I customize? Thank you
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47821
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Subcategory Thumbnail

Post by Jan »

Hi, you can edit the output or override the Phoca Cart component output with your template:

components\com_phocacart\views\category\tmpl\default_header.php

This part displays the subcategories:

Code: Select all

if (!empty($this->subcategories) && (int)$this->t['cv_display_subcategories'] > 0) {
	echo '<div class="ph-subcategories">'.JText::_('COM_PHOCACART_SUBCATEGORIES') . ':</div>';
	echo '<ul>';
	$j = 0;
	foreach($this->subcategories as $v) {
		if ($j == (int)$this->t['cv_display_subcategories']) {
			break;
		}
		echo '<li><a href="'.JRoute::_(PhocacartRoute::getCategoryRoute($v->id, $v->alias)).'">'.$v->title.'</a></li>';
		$j++;
	}
	echo '</ul>';
	echo '<hr />';
}
If you want to display images there, the model must be customized (I will add this change to next version, so this will be no needed in future)


components\com_phocacart\models\category.php - line cca 238
FROM:

Code: Select all

$columns	= 'c.id, c.parent_id, c.title, c.alias, COUNT(c.id) AS numdoc';
			$groupsFull	= 'c.id, c.parent_id, c.title, c.alias';
TO:

Code: Select all

$columns	= 'c.id, c.parent_id, c.title, c.alias, c.image, COUNT(c.id) AS numdoc';
			$groupsFull	= 'c.id, c.parent_id, c.title, c.alias, c.image';

Example - the following code is a modification of above code to display image inside a tag (link to subcategory):

Code: Select all

if (!empty($this->subcategories) && (int)$this->t['cv_display_subcategories'] > 0) {
	echo '<div class="ph-subcategories">'.JText::_('COM_PHOCACART_SUBCATEGORIES') . ':</div>';
	echo '<ul>';
	$j = 0;
	foreach($this->subcategories as $v) {
		
	
		$image = PhocacartImage::getThumbnailName($this->t['pathcat'], $v->image, 'medium');
		if (isset($image->rel)) {
			echo '<a href="'.JRoute::_(PhocacartRoute::getCategoryRoute($v->id, $v->alias)).'"><img src="'. JURI::base(true).'/'.$image->rel.'" alt="" class="img-responsive ph-image" /></a>';
		}
		
		if ($j == (int)$this->t['cv_display_subcategories']) {
			break;
		}
		echo '<li><a href="'.JRoute::_(PhocacartRoute::getCategoryRoute($v->id, $v->alias)).'">'.$v->title.'</a></li>';
		$j++;
	}
	echo '</ul>';
	echo '<hr />';
}
To customize the design - just use the template or Phoca Cart CSS. You can change the size of the thumbnails too:
FROM:

Code: Select all

$image = PhocacartImage::getThumbnailName($this->t['pathcat'], $v->image, 'medium');
TO:

Code: Select all

$image = PhocacartImage::getThumbnailName($this->t['pathcat'], $v->image, 'small');
Jan
If you find Phoca extensions useful, please support the project
Post Reply