Originally Posted by
ryska
Hi yellow1912, nice module. But in center column not showing navigation (name sub-category or image) for others subcategories. Is possibility their display?
In file "/includes/templates/YOURTEMPLATE/templates/tpl_index_product_list.php" find this line:
<?php } // categories_description ?>
BELOW this line, paste the following code :
PHP Code:
<!-- BOF: Display grid of available sub-categories, if any -->
<?php
if (PRODUCT_LIST_CATEGORY_ROW_STATUS == 0) {
// do nothing
} else {
// display subcategories
/**
* require the code to display the sub-categories-grid, if any exist
*/
require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php');
}
?>
<!-- EOF: Display grid of available sub-categories -->
In file "/includes/modules/pages/index/main_template_vars.php" find this line:
$tpl_page_body = 'tpl_index_product_list.php';
ABOVE this line, paste the following code :
PHP Code:
/* ---------------- BOF - THIS MAKES SUB-CATS WORK -------------------- */
$sql = "SELECT cd.categories_name, c.categories_image
FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
WHERE c.categories_id = :categoriesID
AND cd.categories_id = :categoriesID
AND cd.language_id = :languagesID
AND c.categories_status= '1'";
$sql = $db->bindVars($sql, ':categoriesID', $current_category_id, 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');
$category = $db->Execute($sql);
if (isset($cPath) && strpos($cPath, '_'))
{
// check to see if there are deeper categories within the current category
$category_links = array_reverse($cPath_array);
for($i=0, $n=sizeof($category_links); $i<$n; $i++)
{
$sql = "SELECT count(*) AS total
FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
WHERE c.parent_id = :parentID
AND c.categories_id = cd.categories_id
AND cd.language_id = :languagesID
AND c.categories_status= '1'";
$sql = $db->bindVars($sql, ':parentID', $category_links[$i], 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');
$categories = $db->Execute($sql);
if ($categories->fields['total'] < 1)
{
// do nothing, go through the loop
} else {
$categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id
FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
WHERE c.parent_id = :parentID
AND c.categories_id = cd.categories_id
AND cd.language_id = :languagesID
AND c.categories_status= '1'
ORDER BY sort_order, cd.categories_name";
$categories_query = $db->bindVars($categories_query, ':parentID', $category_links[$i], 'integer');
$categories_query = $db->bindVars($categories_query, ':languagesID', $_SESSION['languages_id'], 'integer');
break; // we've found the deepest category the customer is in
}
}
} else {
$categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id
FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
WHERE c.parent_id = :parentID
AND c.categories_id = cd.categories_id
AND cd.language_id = :languagesID
AND c.categories_status= '1'
ORDER BY sort_order, cd.categories_name";
$categories_query = $db->bindVars($categories_query, ':parentID', $current_category_id, 'integer');
$categories_query = $db->bindVars($categories_query, ':languagesID', $_SESSION['languages_id'], 'integer');
}
$categories = $db->Execute($categories_query);
$number_of_categories = $categories->RecordCount();
$new_products_category_id = $current_category_id;
/* ---------------- EOF - THIS MAKES SUB-CATS WORK -------------------- */
This modification was based on bodyjewelrystores code. I haven´t had problems with displaying names of sub-category or image. I hope it will solve your problem.
Bookmarks