Display Category NameLast Update: 18th August, 2005
Article ID: 257



Introduction

There are several different ways to change the category/sub-category heading name to the name of the category/sub-category name itself in the main text section.

Ex: click on a store category/sub-category and the heading in the text area will say category for all the category/sub-category listings. This allows the name of each category/sub-category to be displayed in the main text area only if the category has other categories underneath it. If a category just has products in it this will not work.

Using Breadcrumb Code

This is the easiest way to do it without any other changes to the files.

In catalog/include/classes/breadcrumb.php add the following subroutine:

// start of added code for category/subcategory names
function last() { $trail_size = sizeof($this->_trail); return

$this->_trail[$trail_size-1]['title']; }
// end of added code



After this code about line 22:

function breadcrumb() {
$this->reset();
}

function reset() {
$this->_trail = array();
}



In in catalog/index.php (back it up first!), change the first 2 occurrences of HEADING_TITLE (line 76 & line 254).

From:

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>



To:

<td class="pageHeading"><?php echo $breadcrumb->last(); ?></td>



Using Functions

These code changes require a few more changes.

In catalog/index.php change the first 3 occurances of this code to the following:

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>



To:


<td class="pageHeading"><?php echo HEADING_TITLE . ' ' . tep_get_categories_name($cPath); ?></td>



In catalog/includes/functions/general.php add this code at the bottom of the page before the ?> tag:

////
// TABLES: categories_description
function tep_get_categories_name($who_am_i) {
global $languages_id;
$the_categories_name_query= tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id= '" . $who_am_i . "' and language_id= '" . $languages_id . "'");

$the_categories_name = tep_db_fetch_array($the_categories_name_query);
return $the_categories_name['categories_name'];
}


You will still see the text "Categories" so you can remove just the text in catalog/includes/languages/english/index.php

define('HEADING_TITLE', 'Let\'s See What We Have Here');
define('HEADING_TITLE', 'Categories');



To:

define('HEADING_TITLE', '');
define('HEADING_TITLE', '');


This code change will make each category have the heading name of that category and each sub-category under a category have the same heading name as the category it is under.

If you want each sub-category to show it's own name the catalog/index.php code needs to change from:

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>



To:

<td class="pageHeading"><?php echo HEADING_TITLE . ' ' . tep_get_categories_name($current_category_id); ?></td>

 

 

Trademark Policy | Copyright Policy | Sitemap

Copyright © 2000-2005 osCommerce. All rights reserved.