User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

Spider moonTask

Show a random product image as a category image.

Solution

I solved this at the Joomla template level.

So you need to perform the steps:

  1. Copy file components/com_virtuemart/views/category/tmpl/default.php to templates/YOURTEMPLATE/html/com_virtuemart/category/default.php, if doesn't exist.
  2. Copy file components/com_virtuemart/views/virtuemart/tmpl/default_categories.php to templates/YOURTEMPLATE/html/com_virtuemart/virtuemart/default_categories.php, if doesn't exist.
  3. Create file templates/YOURTEMPLATE/html/com_virtuemart/gruzsnippets/category_random_image.php with the following code:
  4. Edit templates/YOURTEMPLATE/html/com_virtuemart/category/default.php and find the place where the image is outputted. In VM 2.0.7d it's line 105:
    echo $category->images[0]->displayMediaThumb("",false);

    And add the following code above the line:
    include (dirname(__FILE__).DS.'..'.DS.'gruzsnippets'.DS.'category_random_image.php');
  5. Do p.4 for  templates/YOURTEMPLATE/html/com_virtuemart/virtuemart/default_categories.php also.

Options

In the file templates/YOURTEMPLATE/html/com_virtuemart/gruzsnippets/category_random_image.php there is a line:

$ordering_is_set = false;

In my case I needed to use only the first product image, but the ordering in the #__virtuemart_product_medias table was not set. So I needed to make 2 DB queries instead of one to use the first image only.  You may set option to TRUE if you want to reduce the number of queries and don't care the product image ordering.

Comments   

Guest
# Guest 2012-12-12 15:46
Thanks a lot ! That's perfect !!
Guest
# Guest 2012-12-25 18:39
could you make a slight mod to this where i would only have 1 alternative image and that one would be functioning as a rollover swap.
regards.
gruz
# gruz 2012-12-25 19:19
Sorry, I have no time to play around with it. It doesn't seem to be so "slight" as you expect.
MySite
# MySite 2013-08-23 08:54
Hi,

This is now working to me....
I'm with a new version of virtuemart 2.0.20b and it is now working.
gruz
# gruz 2013-08-23 10:25
Now working or not working?
al_bel
# al_bel 2013-10-08 14:02
Perfect job. Works great. Virtuemart 2.0.24b out from the box.

Please register to post comments.

Found a typo? Please select it and press Ctrl + Enter.
FaLang translation system by Faboba
Електронна бібліотека «Exlibris»: історичні дослідження, мемуаристика, публіцистика, художня література Українська етнографія: книги, курси лекцій, статті й матеріали, мапи, фотоальбоми, веб-ресурси Правителі України: портрети, життєписи, матеріали Твори Адріана Кащенка: романтика козацьких часів Народна війна 1917-1932

See a typo?

Select the text block and press

CTRL+Enter

Comments

  • NotificationAry - get emails on Joomla content is submitted, added or changed

    Berndi Berndi 30.06.2019 11:45
    The fields %TO_NAME% and %TO_USERNAME% are empty

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    Berndi Berndi 30.06.2019 11:43
    My fault, I made it

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    Berndi Berndi 30.06.2019 10:46
    I did. Now I'm asking me how to put the surename into the email... :-|

    Read more...

     
  • NavigationAry - navigate between Joomla menu items like between articles using "prev - next"

    Berndi Berndi 29.06.2019 15:59
    I also miss content in %TO_NAME%

    Read more...

     
  • NotificationAry - get emails on Joomla content is submitted, added or changed

    Berndi Berndi 29.06.2019 15:15
    Hi gruz, I have the problem, that when I use the %AUTHOR% tag, the plugin dosen't send the author ...

    Read more...