Forums / Templates, Stylesheets, Page Layout / Display Category Description below category Title on the Product page

Display Category Description below category Title on the Product page

Locked

Views: 10,855

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
20 Mar 2009, 2:38 AM
#1
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Display Category Description below category Title on the Product page

ZenCart 1.3.7

Hi All

What I want to do is to display the Category Description on the Products page (I already have it on the categories page), but I cannot seem to get it to work

I have located where I want it to display, below this section of code

/includes/templates/my_templat/templates/tpl_product_info_display.php

<!--bof Category Icon -->
<?php if ($module_show_categories != 0) {?>
<?php
/**
 * display the category icons
 */
require($template->get_template_dir('/tpl_modules_category_icon_display.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_icon_display.php'); ?>
<?php } ?>
<!--eof Category Icon -->

I have found the code that displays the Categories description on the categories page
/includes/templates/my_templat/templates/tpl_index_categories.php

<?php
// categories_description
    if ($current_categories_description != '') {
?>
<div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description;  ?></div>
<?php } // categories_description ?>

However adding this code to the products page does nothing,

<!--bof Category Icon -->
<?php if ($module_show_categories != 0) {?>
<?php
/**
 * display the category icons
 */
require($template->get_template_dir('/tpl_modules_category_icon_display.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_icon_display.php'); ?>
<?php } ?>
<!--eof Category Icon -->

<!--added nigel -->
<?php
// categories_description
    if ($current_categories_description != '') {
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description;  ?></div>
<?php } // categories_description ?>
<!--end nigel -->

obviously i am missing the code that gets the Value of $current_Categories_description, It seems to be on the
/includes/modules/pages/index/main_template_vars.php

$current_categories_description = "";
// categories_description
$sql = "SELECT categories_description 
        FROM " . TABLE_CATEGORIES_DESCRIPTION . "
        WHERE categories_id= :categoriesID
        AND language_id = :languagesID";

$sql = $db->bindVars($sql, ':categoriesID', $current_category_id, 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');
$categories_description_lookup = $db->Execute($sql);
if ($categories_description_lookup->RecordCount() > 0) {
  $current_categories_description = $categories_description_lookup->fields['categories_description'];
}

page however i can't see where this is being called on the categories page (so i can copy the call to the products page)

What is frustrating is that I can access the $current_category_id and I realise i could use this to get the description by cutting and pasting the above function to the products page, however I am sure that there should be an inbuilt function call thingie

Any help would be greatly appreciated

Webzings Design
Semi retired from Web Design

20 Mar 2009, 1:32 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Category Description below category Title on the Product page

If you add this code to the tpl_product_info_display.php in your templates and overrides you should be able to manipulate the categories_description ...

<?php
$current_categories_description = "";
// categories_description
$sql = "SELECT categories_description
        FROM " . TABLE_CATEGORIES_DESCRIPTION . "
        WHERE categories_id= :categoriesID
        AND language_id = :languagesID";

$sql = $db->bindVars($sql, ':categoriesID', $current_category_id, 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');
$categories_description_lookup = $db->Execute($sql);
if ($categories_description_lookup->RecordCount() > 0) {
  $current_categories_description = $categories_description_lookup->fields['categories_description'];
}
?>

<?php
// categories_description
    if ($current_categories_description != '') {
?>
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description;  ?></div>
<?php } // categories_description ?>

The first part is getting it and the second part is the display ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

21 Mar 2009, 11:27 PM
#3
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Display Category Description below category Title on the Product page

Thanks for that, It works perfectly

Webzings Design
Semi retired from Web Design

22 Mar 2009, 3:24 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Category Description below category Title on the Product page

Thanks for the update that you were able to get this code for displaying the categories_description on your product info pages show ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

4 Sep 2009, 11:59 AM
#5
predmond avatar

predmond

New Zenner

Join Date:
Apr 2007
Posts:
36
Plugin Contributions:
0

Re: Display Category Description below category Title on the Product page

This is fantastic! I have a client who wants the category description to display for each product as normal, but occasionally wants one product to have its own description. I chnages the code a little, to make this happen:

<?php
//////////////////////////////////////////////////////////////////////
// display category description if there is no product description  //
//////////////////////////////////////////////////////////////////////

$current_categories_description = "";
// categories_description
$sql = "SELECT categories_description FROM " . TABLE_CATEGORIES_DESCRIPTION . " WHERE categories_id= :categoriesID AND language_id = :languagesID";

$sql = $db->bindVars($sql, ':categoriesID', $current_category_id, 'integer');
$sql = $db->bindVars($sql, ':languagesID', $_SESSION['languages_id'], 'integer');

//echo $sql;

$categories_description_lookup = $db->Execute($sql);
if ($categories_description_lookup->RecordCount() > 0) {
  $current_categories_description = $categories_description_lookup->fields['categories_description'];
}
?>


<?php if ($products_description != '') { ?>
<!--bof Product description -->
<div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
<!--eof Product description -->
<?php } else { 
// categories_description
    if ($current_categories_description != '') {
?>
<!--bof Categories description -->
<div id="indexProductListCatDescription" class="content"><?php echo $current_categories_description;  ?></div>
<!--eof Categories description -->
<?php } // categories_description 
?>

Maybe it will come in helpful for someone? Sure, you could just copy and paste the category description into the product description, but then if the category description was to change, you would have to update it in each product - this way you don't!!

Cheers,
Pat

4 Sep 2009, 1:06 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Display Category Description below category Title on the Product page

Nice tweak! :)

And if you really didn't want any description for a particular product, you could make its description

 

(non-breaking space) so the description content would not be null.