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

Change in the way category image is retrieved?

Started by ginxy33, May 13, 2013, 20:20:46 PM

Previous topic - Next topic

ginxy33

I programmed a mod to show categories in a slider on a home page. Now I updated to  VirtueMart 2.0.20b and I can't get the images to show. It throws and error  stating that I can't use "displayMediaThumb" on a none object.
Here is my original code that worked before
<?php foreach ($categories as $category) {
$caturl JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattext $category->images[0]->displayMediaThumb("",false);   ?>

<li><?php echo JHTML::link($caturl$cattext);?></li>
<?php ?>


I can get the category name and the url to work with no problem. I did a var_dump and came up with this object.
object(stdClass)#288 (9) {
  ["virtuemart_category_id"]=>
  string(1) "3"
  ["category_name"]=>
  string(5) "Gifts"
  ["category_description"]=>
  string(15) "<p>
Gifts</p>"
  ["metadesc"]=>
  string(0) ""
  ["metakey"]=>
  string(0) ""
  ["customtitle"]=>
  string(0) ""
  ["slug"]=>
  string(5) "gifts"
  ["virtuemart_media_id"]=>
  array(1) {
    [0]=>
    string(2) "25"
  }
  ["childs"]=>
  array(0) {
  }
}
<li><a href="/shop/gifts" >Gifts</a></li>


Any ideas how I can now retrieve the image information?

Mathalis

Hello,

It was working before or ? Can you rexplain your problem ?


Regards

mySITE4u

Quote from: ginxy33 on May 13, 2013, 20:20:46 PM
I programmed a mod to show categories in a slider on a home page. Now I updated to  VirtueMart 2.0.20b and I can't get the images to show. It throws and error  stating that I can't use "displayMediaThumb" on a none object.
Here is my original code that worked before
<?php foreach ($categories as $category) {
$caturl JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattext $category->images[0]->displayMediaThumb("",false);   ?>

<li><?php echo JHTML::link($caturl$cattext);?></li>
<?php ?>


I can get the category name and the url to work with no problem. I did a var_dump and came up with this object.
object(stdClass)#288 (9) {
  ["virtuemart_category_id"]=>
  string(1) "3"
  ["category_name"]=>
  string(5) "Gifts"
  ["category_description"]=>
  string(15) "<p>
Gifts</p>"
  ["metadesc"]=>
  string(0) ""
  ["metakey"]=>
  string(0) ""
  ["customtitle"]=>
  string(0) ""
  ["slug"]=>
  string(5) "gifts"
  ["virtuemart_media_id"]=>
  array(1) {
    [0]=>
    string(2) "25"
  }
  ["childs"]=>
  array(0) {
  }
}
<li><a href="/shop/gifts" >Gifts</a></li>


Any ideas how I can now retrieve the image information?


Hi!
Open mod_virtuemart_categories.php

find these lines:

$cache = & JFactory::getCache('com_virtuemart','callback');
$categories = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList'
),$vendorId, $category_id );

near line 40

Then put in this line:
$categoryModel->addImages($categories,1);

This is it! :)