Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Categories description text -- simple method


Yikes

Recommended Posts

Instead of altering meta tags for the categories, I thought of a SIMPLE way to add category-specific text to each category page. (Yes, I know this can be accomplished through the categories description contrib, too!)

 

How simple is it?

-I edited only ONE page: catalog/default.php

-And I made only ONE change to the database.

-However, I don't have the php knowledge to write an admin mod -- sorry! Perhaps someone else who knows how could add that to admin/categories.php under the edit-categories action?

 

Since this is so simple, I hope no one minds my adding it here, instead of as a contrib.

 

STEP 1:

In default.php, find the <tr> which contains your category heading title and then the category image, and add this new row beneath that row. I have modified my file too much to point to exact code, but it should be just a few lines ABOVE this: <?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING_COL); ?> Add this row INSIDE the table that ends just above the this line and the separator line above it.

 

 

>>>>>>ADD THIS TO DEFAULT.PHP<<<<<<<<

/////////////////////////////////////////////////////////

<!-- this row holds the categories_text description -->

<tr>

<td colspan=2 class="main">

<?php

function tep_get_category_text($category_id) {

global $languages_id;

 

$category_query = tep_db_query("select categories_text from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $languages_id . "'");

$category = tep_db_fetch_array($category_query);

 

return $category['categories_text'];

}

 

echo tep_get_category_text($current_category_id);

?>

</td>

</tr>

<!-- end of categories_text row -->

/////////////////////////////////////////////////////////

 

 

STEP 2:

Run this query on your database:

/////////////////////////////////////////////////////////

 

ALTER TABLE `categories_description` ADD `categories_text` TEXT DEFAULT NULL ;

 

ALTER TABLE `categories_description` ADD FULLTEXT (

`categories_text`

);

/////////////////////////////////////////////////////////

 

That's it! This will make the categories_text appear just below the name of your category. As I said, there is no admin mod, so you have to do it all directly through the database right now. I was toying around with an admin mod, but don't know how to add it to admin/categories.php. Anywhere else, the query line would be something like:

 

UPDATE `categories_description` SET `categories_text` = ' <<add text here >> ' WHERE `categories_id` = ' <<use $current_category_id variable>> ' AND `language_id` = ' <<use $current_language_id variable >> ' LIMIT 1 ;

 

 

Well, that's it! I hope someone will find it useful, and maybe we'll see an admin mod someday.

 

Best,

Yikes!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...