News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Additional images for categories

Started by Tkheun, December 20, 2016, 11:54:42 AM

Previous topic - Next topic

Tkheun

Hi there!

I need to display additional images at category pages. How do I do that?  Normally default template doesn't display even a main image of category.

Studio 42

The minimum code is :
echo $this->category->images[0]->displayMediaThumb("",false);
in JOOMLAROOT\components\com_virtuemart\views\category\tmpl\default.php
or better in your template do an overide in
YOURTEMPLATE\html\com_virtuemart\category\default.php
Note : some stupid framework can have other subfolders, eg.warp framework used by yootheme, can have 3 or 4 subfolders, i searched 2 hours last day, because vmuikit now add own folder too for layout file overides.

Tkheun

Thank you. But it this code allowed me to display only main image. Additional images still doesn't work :'(

Spiros Petrakis

I think you must first get all the images because they are not available by default


$catModel = VmModel::getModel('Category');
$catModel->addImages($categories);


then echo the images


foreach ($category->images as $image) {
  echo $image->displayMediaThumb("",false);
}
Joomla templates and extensions development
https://www.yourgeek.gr

Tkheun

#4
<?php
$catModel 
VmModel::getModel('Category');
$catModel->addImages($categories);

foreach (
$category->images as $image) {
  echo 
$image->displayMediaThumb("",false);
}
?>

Like that? It doesn't work :(

Also I want them to be displayed like images in product - main image on top and additional images below. As I understand there should be separated code to do that?

Studio 42

Have you try my code?
echo $this->category->images[0]->displayMediaThumb("",false);

Tkheun

#6
Quote from: Studio 42 on December 21, 2016, 09:46:48 AM
Have you try my code?
echo $this->category->images[0]->displayMediaThumb("",false);
Yes. I wrote you an answer above - it shows main image, but doesn't show additionals.

Studio 42

SO you have to mix my code with Tkheun code, this is the simplified code
<?php
$catModel = VmModel::getModel('Category');
$catModel->addImages($this->category);

foreach ($this->category->images as $image) {
  echo $image->displayMediaThumb("",false);
}
?>

Tkheun

#8
I appreciate your help! This time it worked. This is how it displayed images: http://igc.oscargo.ru/catalog/split-sistemy/comfort and this is how I need it to be http://igc.oscargo.ru/catalog/split-sistemy/comfort/ras-rac-07nhg-detail

Could you tell me how to split the code?

Ghost

See default_images.php and default_images_additional.php in /components/com_virtuemart/views/productdetails/tmpl/.

Tkheun

Quote from: Ghost on December 21, 2016, 11:28:15 AM
See default_images.php and default_images_additional.php in /components/com_virtuemart/views/productdetails/tmpl/.
Looked thru both files. Couldn't make it work.

Tkheun

#11
Mod edit: annoying bump message removed. Please read http://forum.virtuemart.net/index.php?topic=104795.0

Studio 42

read my answers the last is right and file is
in JOOMLAROOT\components\com_virtuemart\views\category\tmpl\default.php
or better in your template do an overide in
YOURTEMPLATE\html\com_virtuemart\category\default.php
Note : some stupid framework can have other subfolders, eg.warp framework used by yootheme, can have 3 or 4 subfolders, i searched 2 hours last day, because vmuikit now add own folder too for layout file overides.

Tkheun

Quote from: Studio 42 on December 22, 2016, 08:19:47 AM
read my answers the last is right and file is
I have read your answer. Have you read mine? Especially #8 where I sad that I need to split your code?

Studio 42

Last time


$catModel = VmModel::getModel('Category');
$catModel->addImages($this->category);

foreach ($this->category->images as $image) {
  echo $image->displayMediaThumb("",false);
}

in JOOMLAROOT\components\com_virtuemart\views\category\tmpl\default.php
or better in your template do an overide in
YOURTEMPLATE\html\com_virtuemart\category\default.php
Note : some stupid framework can have other subfolders, eg.warp framework used by yootheme, can have 3 or 4 subfolders, i searched 2 hours last day, because vmuikit now add own folder too for layout file overides.

I cannot explain better.