Problem solved.
In my efforts to understand why the code I had been using failed to render properly, I led myself on a weeks long wild goose chase in my obsession to discover the answer.
I was so focused on the idea that the code I introduced should have worked, I overlooked the fact that I failed to introduce a new image element to my array AND in the process of trying all manner of variations of the code I thought should work, ignored the existing category name element that I knew did work.
Here is the solution in the hope I spare some other person looking to do something similar, valuable time. (I am only including the parts of categories_ul_generator.php that needed changes for my solution to work and to give a reference point for those interested.)
PHP Code:
global $languages_id, $db;
$this->data = array();
// I am using * as it fetches all fields.
$categories_query = "select *
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and c.categories_status=1 " .
" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
" order by c.parent_id, c.sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
while (!$categories->EOF) {
// The following is the ORIGINAL bit of code I needed to change. Compare it to the next line to see the solution.
// $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
// In order to display each category image, a new element must be included in the array. In this case the element "image" is introduced.
$this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'image' => $categories->fields['categories_image'], 'count' => 0);
$categories->MoveNext();
}
}
Now that the element has been added to the array, I can complete my solution by including both the 'name' and 'image' elements in my result.
PHP Code:
function buildBranch($parent_id, $level, $submenu=true, $parent_link='')
{
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
{
foreach($this->data[$parent_id] as $category_id => $category) {
$category_link = $parent_link . $category_id;
if (($this->data[$category_id])) {
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
$result .= sprintf($this->child_start_string, '');
}
$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">' . zen_image(DIR_WS_IMAGES . $category['image'], $category['name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $category['name'] . '</a>';
If I had included all this information from the get go, someone may have seen the problem and advised me on a solution when I first posted. My bad, lesson learned.
All this said, if someone knows the proper code to specify the height and width of each image in the $result I posted, please advise, it would be greatly appreciated.
I realize I am using SUBCATEGORY_IMAGE_WIDTH and SUBCATEGORY_IMAGE_HEIGHT but I am only using the top category for my menu and I'm not sure this is the correct code. If I am using the correct code, I'd like it clarified.
Thanks!