VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: scotous on August 20, 2012, 22:05:23 PM

Title: Multiple Category Images in Category Page
Post by: scotous on August 20, 2012, 22:05:23 PM
What I wanted to achieve is to have more than 1 category image shown in the category page.

From what I can remember I had achieved it in a previous version of vm but from what I see now i can't get it right.

The string from other posts was
<?php if ($this->category->virtuemart_media_id) echo $this->category->images[0]->displayMediaFull("", false); ?>
but this only shows the first image of the category.

Any way this could work?

Title: Re: Multiple Category Images in Category Page
Post by: ivus on August 20, 2012, 22:44:49 PM
Hi scotous,

That's correct.

Quote

<?php

  if ($this->category->virtuemart_media_id) :
    foreach ($this->category->images as $catimg) :
      echo $catimg->displayMediaFull("", false);
    endforeach;
  endif;

?>


You need some sort of loop to display all the image. Simple PHP stuff.

Good luck, I hope this helps. :D
Title: Re: Multiple Category Images in Category Page
Post by: scotous on August 20, 2012, 22:58:35 PM
Dear Ivus,

Thank you very much for your assistanse.

I try the below code but it still only shows the 1st picture.

I tried the foreach for a lil bit but couldnt figure it out.
What I see is that the virtuemart_media_id is different for every image but the virtuemart_category_id is correct.

Did this code worked for you?
Title: Re: Multiple Category Images in Category Page
Post by: ivus on August 20, 2012, 23:05:16 PM
Hi scotous,

I don't use Category Images in my site.

What you'll need to do is find the items in your $this->category->virtuemart_media_id array and loop through each of those to output the images.

The code I wrote, was just an example based on the code you pasted.
Title: Re: Multiple Category Images in Category Page
Post by: scotous on August 20, 2012, 23:12:27 PM
Dear Ivus,

When you say find the items in the $this->category->virtuemart_media_id array what do you mean?

I am aware after diggint the sql that all the images i uploaded in a category have different virtuemart_media_id but same virtuemart_category_id and the first thing i did was to check if that could work.

But it didnt

:/
Title: Re: Multiple Category Images in Category Page
Post by: ivus on August 20, 2012, 23:15:58 PM
echo '<pre>'; print_r($this->category->virtuemart_media_id); echo '</pre>';

You won't get far if you don't know if the image information is in that array. The fact that VM is only showing the first image may mean that only ONE image is passed to that page?
Title: Re: Multiple Category Images in Category Page
Post by: scotous on August 20, 2012, 23:23:51 PM
What i get from this is

Array
(
   
Title: Re: Multiple Category Images in Category Page
Post by: scotous on August 20, 2012, 23:27:13 PM
Ok i now now what 1-4-5 means.

These are the virtuemart media ids that are allocated in this category only.
So the correct ids are passed.

but still only the first is shown
Title: Re: Multiple Category Images in Category Page
Post by: ivus on August 20, 2012, 23:42:26 PM
Hi scotous,

that's right... they're the media ID's you need to work with... unfortunately, there's no frontend model/helper that uses mediaIDs so your task gets way more difficult from here on...

I don't use category images otherwise I'd be able to continue helping you, but if you know PHP, all you need to do is write an SQL query to grab the location of the files associated with the ID out of the database, then display it on your page.

Good luck.

Title: Re: Multiple Category Images in Category Page
Post by: scotous on August 20, 2012, 23:48:32 PM
The products page work exactly the same way but they do show more than one images
I ll go to sleep now and will recheck it again tomorrow

Thank you very much again!
Title: Re: Multiple Category Images in Category Page
Post by: scotous on August 26, 2012, 20:40:26 PM
I have 40% understood the way array's work but still coulnd get the solution.

The array shows me that the image is passed

Array
(