Okay. Here's the full error I am getting:
The full file looks like this:
<?php
/*
* @author: Jaoman
* @copyright (C) - Jaoman 2012
*
* @package: mod_displaythumbnail
* @file: helper.php
* @purpose: This helper.php acts the Model for the mod_displaythumbnail module, providing logic support.
* It connects to the VirtueMart framework, retrieves product data, parses data for image thumbnails location,
* and returns the image.
*/
// No direct access outside Joomla.
defined ('_JEXEC') or die ('Restricted access');
// Configures VirtueMart variables and stores them into cache.
if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');
VmConfig::loadConfig();
// Loads the language file of com_virtuemart.
JFactory::getLanguage()->load('com_virtuemart');
// Loads the VirtueMart image class.
if (!class_exists( 'VmImage' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'image.php');
// Loads VirtueMart Models.
if (!class_exists( 'VirtueMartModelProduct' ))
{
JLoader::import( 'product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' );
}
if (!class_exists ('VmModel')) require (JPATH_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php');
// Loads VirtueMart category model.
if (!class_exists( 'VirtueMartModelCategory' )) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'category.php');
class ThumbnailHelper
{
/*
* @function: get_thumbnail
* @description: Retrieves the thumbnail image of a random VirtueMart product
* @param: None.
* @return: String with html to display an image.
*/
function get_thumbnail ()
{
$category_list = $this->get_categories();
$category = array_rand ($category_list);
$random_product = $this->get_random_product ($category);
$image = $random_product->images [0]->displayMediaThumb('class="product-image"', true, 'class="modal"', true, true);
return $image;
}
/*
* @function: get_random_product
* @description: Retrieves a random product from a VM category.
* @param: Category with at least one product.
* @return: VM Product object.
*/
function get_random_product ($category)
{
$product_model = VmModel::getModel ('product');
$category_id = $category->virtuemart_category_id;
$products = $product_model->getProductsInCategory ($category_id);
$product_model->addImages ($products, 1);
$product_population = count ($products);
$random_product_key = rand (0, $product_population -1);
return $products [$random_product_key];
}
/*
* @function: get_categories
* @description: Retrieves an array of associative arrayss of the categories in VirtueMart.
* @param: None.
* @return: Array full of associative arrays. Keys are numbers.
*/
function get_categories ()
{
// Returns the model object for VirtueMart categories.
$category_model = VmModel::getModel ('category');
// Returns an array of category objects. Each object is an associative array.
$category_list = $category_model->getCategories ();
return $category_list;
}
}
?>
You can't tell from here, but when you plug it into an editor, line 49 is "[]$category_list = $this->get_categories();[/i]".
I know the code itself works because, when I remove the other functions and just run all of it out of get_thumbnail, the module executes without a hitch. Does anyone have an answer?