Help - Search - Members - Calendar
Full Version: Category Description Mod
CubeCart Forums > CubeCart Version 3 > Installation & Upgrade Help (Version 3)
louisplatt
In lang.inc.php find:

CODE
'category_name' => "Category Name:",


After this add the following:

CODE
'category_desc' => "Category Description:",


Save file.

In admin/categories/index.php find:

CODE
$record["cat_name"] = $db->mySQLSafe($_POST['cat_name']);


After it, add:

CODE
$record["cat_desc"] = $db->mySQLSafe($_POST['cat_desc']);


Find the line:

CODE
$query = "SELECT cat_id, cat_name, cat_father_id FROM ".$config['dbprefix']."CubeCart_category ORDER BY cat_id DESC";


Replace it with:

CODE
$query = "SELECT cat_id, cat_name, cat_desc, cat_father_id FROM ".$config['dbprefix']."CubeCart_category ORDER BY cat_id DESC";


Finally, find:

CODE
 <tr>
   <td class="tdText"><?php echo $lang['admin']['categories']['category_name'];?></td>
   <td>
     <input name="cat_name" type="text" class="textbox" value="<?php echo $results[0]['cat_name']; ?>" maxlength="255">
   </td>
 </tr>


After that, add:

CODE
<tr>
   <td class="tdText"><?php echo $lang['admin']['categories']['category_desc'];?></td>
   <td>
     <textarea name="cat_desc" class="textbox" cols="50" rows="5"><?php echo $results[0]['cat_desc']; ?></textarea>
   </td>
 </tr>




Now for the frontend

Open skins/classic/styletemplates/content/viewCat.tpl

Add

CODE
{TXT_CAT_DESC}
Where you want the description to appear.

Save.

Open includes/content/viewCat.inc.php

Find

CODE
$currentCatQuery = "SELECT cat_name, cat_father_id, cat_id FROM ".$config['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId']);


replace with:

CODE
$currentCatQuery = "SELECT cat_name, cat_desc, cat_father_id, cat_id FROM ".$config['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId']);


Find:
CODE
    $view_cat->assign("CATEGORIES",$categoriesData);


After it, add:

CODE
$view_cat->assign("TXT_CAT_DESC",$currentCat[0]['cat_desc']);


Find:

CODE
    
$view_cat->assign("CURRENT_DIR",getCatDir($categoryArray, $currentCat[0]['cat_name'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $sep=$config['dirSymbol'],$link=TRUE));


replace with:


CODE
    
$view_cat->assign("CURRENT_DIR",getCatDir($categoryArray, $currentCat[0]['cat_name'],$currentCat[0]['cat_desc'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $sep=$config['dirSymbol'],$link=TRUE));


Save file..

Add a new field to the cubecart_categories table called cat_desc

CODE
ALTER TABLE `CubeCart_category` ADD `cat_desc` VARCHAR( 250 ) NOT NULL AFTER `cat_name`;


That's all. sorcerer.gif
evilhomer
is this mod for cc3 or cc2?
Mobie
QUOTE(evilhomer @ Apr 2 2005, 02:32 PM)
is this mod for cc3 or cc2?

UH.... look at the top:
CODE
 CubeCart Forums -> CubeCart™ Version 3 -> Installation & Upgrade Help
And
CODE
Open skins/classic/styletemplates/content/viewCat.tpl
Looks very Ccv3 to me....? tongue.gif

Mobie
louisplatt
any chance some of my 'mods' can be added to a list somewhere? They seemed to have died a slow death.
shop.lightspeed.net.au
http://cubecart.com/site/downloads smile.gif

Save em, zip em, and post em wink.gif
Mysty
QUOTE(louisplatt @ Apr 2 2005, 12:27 AM)
Open includes/content/viewCat.inc.php

Find

CODE
$currentCatQuery = "SELECT cat_name, cat_father_id, cat_id FROM ".$config['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId']);


replace with:

CODE
$currentCatQuery = "SELECT cat_name, cat_desc, cat_father_id, cat_id FROM ".$config['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId']);


Find:
CODE
    $view_cat->assign("CATEGORIES",$categoriesData);


After it, add:

CODE
$view_cat->assign("TXT_CAT_DESC",$currentCat[0]['cat_desc']);


Find:

CODE
    
$view_cat->assign("CURRENT_DIR",getCatDir($categoryArray, $currentCat[0]['cat_name'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $sep=$config['dirSymbol'],$link=TRUE));


replace with:


CODE
    
$view_cat->assign("CURRENT_DIR",getCatDir($categoryArray, $currentCat[0]['cat_name'],$currentCat[0]['cat_desc'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $sep=$config['dirSymbol'],$link=TRUE));

Having problems with this part - cannot find the lines to change.

My viewcat.inc.php file is below.

CODE
<?php
/*
+--------------------------------------------------------------------------
|   CubeCart v3.0.0
|   ========================================
|   by Alistair Brookbanks
|    CubeCart is a Trade Mark of Devellion Limited
|   (c) 2005 Devellion Limited
|   Devellion Limited,
|   Westfield Lodge,
|   Westland Green,
|   Little Hadham,
|   Nr Ware, HERTS.
|   SG11 2AL
|   UNITED KINGDOM
|   http://www.devellion.com
|    UK Private Limited Company No. 5323904
|   ========================================
|   Web: http://www.cubecart.com
|   Date: Friday, 1 July 2005
|   Email: info@cubecart.com
|    License Type: CubeCart is NOT Open Source Software and Limitations Apply
|   Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
|    viewCat.inc.php
|   ========================================
|    Display the Current Category    
+--------------------------------------------------------------------------
*/
if(!isset($config)){
    echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
    exit;
}

if(isset($_GET['page'])){
    
    $page = $_GET['page'];

} else {
    
    $page = 0;

}

$view_cat = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/viewCat.tpl");
////////////////////////
// BUILD SUB CATEGORIES
////////

if(isset($_GET['catId'])) {
// build query
$query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY cat_name ASC";

// query database
$subCategoroies = "";
$subCategoroies = $db->select($query);

}

if(isset($_GET['catId']) && $_GET['catId']>0 && $subCategoroies == TRUE) {

// loop results
for ($i=0; $i<count($subCategoroies); $i++){

     if(empty($subCategoroies[$i]['cat_image'])){
   $view_cat->assign("IMG_CATEGORY",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/catnophoto.gif");
     } else {
   $view_cat->assign("IMG_CATEGORY",$GLOBALS['rootRel']."images/uploads/".$subCategoroies[$i]['cat_image']);
     }
 
 $view_cat->assign("TXT_LINK_CATID",$subCategoroies[$i]['cat_id']);

 $view_cat->assign("TXT_CATEGORY", $subCategoroies[$i]['cat_name']);
 
 $view_cat->assign("NO_PRODUCTS", $subCategoroies[$i]['noProducts']);
 
 $view_cat->parse("view_cat.sub_cats.sub_cats_loop");
    
    } // end loop results
$view_cat->parse("view_cat.sub_cats");
} // end $subCategoroies == TRUE

////////////////////////////
// BUILD PRODUCTS
///////////


// build query
if(isset($_GET['searchStr'])){

    $searchwords = split ( "[ ,]", $_GET['searchStr']);  
    foreach($searchwords as $word){
 $searchArray[]=$word;
    }

    $noKeys = count($searchArray);
    $like = "";
    for ($i=0; $i<$noKeys;$i++) {
 
 $ucSearchTerm = strtoupper($searchArray[$i]);
 if(($ucSearchTerm!=="AND")AND($ucSearchTerm!=="OR")){
     
     $like .= "(name LIKE '%".$searchArray[$i]."%' OR description LIKE '%".$searchArray[$i]."%' OR productCode LIKE '%".$searchArray[$i]."%') OR ";
     
     // see if search terrm is in database
     $searchQuery = "SELECT id FROM ".$glob['dbprefix']."CubeCart_search WHERE searchstr='".$ucSearchTerm."'";
     $searchLogs = $db->select($searchQuery);
     
     $insertStr['searchstr'] = $db->mySQLsafe($ucSearchTerm);
     $insertStr['hits'] = $db->mySQLsafe(1);
     $updateStr['hits'] = "hits+1";
     
     if($searchLogs == TRUE) {
   
   $db->update($glob['dbprefix']."CubeCart_search",$updateStr,"id=".$searchLogs[0]['id'],$quote = "");
     
     } elseif(!empty($_GET['searchStr'])) {
   
   $db->insert($glob['dbprefix']."CubeCart_search",$insertStr);
     
     }
     
 } else {
     
     $like = substr($like,0,strlen($like)-3);
     $like .= $ucSearchTerm;
 
 }  

    }
    $like = substr($like,0,strlen($like)-3);
    
    $productListQuery = "SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory WHERE ".$like;
    
} elseif($_GET['catId']=="saleItems" && $config['saleMode']>0) {
    
    $productListQuery = "SELECT ".$glob['dbprefix']."CubeCart_cats_idx.cat_id, ".$glob['dbprefix']."CubeCart_cats_idx.productId, productCode, quantity, description, image, price, name, popularity, sale_price, stock_level, useStockLevel FROM ".$glob['dbprefix']."CubeCart_cats_idx INNER JOIN ".$glob['dbprefix']."CubeCart_inventory ON ".$glob['dbprefix']."CubeCart_cats_idx.productId = ".$glob['dbprefix']."CubeCart_inventory.productId WHERE sale_price > 0";

} else {
    
$productListQuery = "SELECT ".$glob['dbprefix']."CubeCart_cats_idx.cat_id, ".$glob['dbprefix']."CubeCart_cats_idx.productId, productCode, quantity, description, image, price, name, popularity, sale_price, stock_level, useStockLevel FROM ".$glob['dbprefix']."CubeCart_cats_idx INNER JOIN ".$glob['dbprefix']."CubeCart_inventory ON ".$glob['dbprefix']."CubeCart_cats_idx.productId = ".$glob['dbprefix']."CubeCart_inventory.productId WHERE ".$glob['dbprefix']."CubeCart_cats_idx.cat_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY ".$glob['dbprefix']."CubeCart_inventory.name ASC";

    
}

$productResults = $db->select($productListQuery, $config['productPages'], $page);

// get different languages
if($productResults == TRUE && $lang_folder !== $config['defaultLang']){

    for($i=0;$i<count($productResults);$i++){
    
 if(($val = prodAltLang($productResults[$i]['productId'])) == TRUE){
     
   $productResults[$i]['name'] = $val['name'];
   $productResults[$i]['description'] = $val['description'];
 
 }
 
    }

}

$totalNoProducts = $db->numrows($productListQuery);

// get current category info
    if(isset($_GET['catId'])){
    $currentCatQuery = "SELECT cat_name, cat_father_id, cat_id, cat_image FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId']);
    $currentCat = $db->select($currentCatQuery);
    }

 if(!empty($currentCat[0]['cat_image'])) {
     $view_cat->assign("IMG_CURENT_CATEGORY","images/uploads/".$currentCat[0]['cat_image']);
     $view_cat->assign("TXT_CURENT_CATEGORY",$currentCat[0]['cat_name']);
     $view_cat->parse("view_cat.cat_img");
 }

    if(isset($_GET['searchStr'])){
 
 $view_cat->assign("TXT_CAT_TITLE",$lang['front']['viewCat']['search_results']);
    
    } elseif($_GET['catId']=="saleItems" && $config['saleMode']>0) {
 
 $view_cat->assign("TXT_CAT_TITLE",$lang['front']['viewCat']['sale_items']);
    
    } else {
 
 $view_cat->assign("TXT_CAT_TITLE",$currentCat[0]['cat_name']);
    
    }
    
    $view_cat->assign("LANG_IMAGE",$lang['front']['viewCat']['image']);
    $view_cat->assign("LANG_DESC",$lang['front']['viewCat']['description']);
    $view_cat->assign("LANG_PRICE",$lang['front']['viewCat']['price']);
    $view_cat->assign("PAGINATION",$db->paginate($totalNoProducts, $config['productPages'], $page, "page"));

// repeated region
if($productResults == TRUE){
    
    if($_GET['catId']>0){
    
 $view_cat->assign("LANG_CURRENT_DIR",$lang['front']['viewCat']['products_in']);
 $view_cat->assign("CURRENT_DIR",getCatDir($currentCat[0]['cat_name'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $link=TRUE));
    
    }
    
    for ($i=0; $i<count($productResults); $i++){
    
 // alternate class
 $view_cat->assign("CLASS",cellColor($i, $tdEven="tdEven", $tdOdd="tdOdd"));

 if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$productResults[$i]['image'])){
     
     $view_cat->assign("SRC_PROD_THUMB",$GLOBALS['rootRel']."images/uploads/thumbs/thumb_".$productResults[$i]['image']);
 } else {
     $view_cat->assign("SRC_PROD_THUMB",$GLOBALS['rootRel']."skins/".$config['skinDir']."/styleImages/thumb_nophoto.gif");
 }


 $view_cat->assign("TXT_TITLE",$productResults[$i]['name']);  

 $view_cat->assign("TXT_DESC",substr(strip_tags($productResults[$i]['description']),0,$config['productPrecis'])."&hellip;");

 if(salePrice($productResults[$i]['price'], $productResults[$i]['sale_price'])==FALSE){
     $view_cat->assign("TXT_PRICE",priceFormat($productResults[$i]['price']));
 } else {
     $view_cat->assign("TXT_PRICE","<span class='txtOldPrice'>".priceFormat($productResults[$i]['price'])."</span>");
 }
 $salePrice = salePrice($productResults[$i]['price'], $productResults[$i]['sale_price']);
 
 $view_cat->assign("TXT_SALE_PRICE", priceFormat($salePrice));

 if(isset($_GET['add']) && isset($_GET['quan'])){
     
     $view_cat->assign("CURRENT_URL",str_replace(array("&amp;add=".$_GET['add'],"&amp;quan=".$_GET['quan']),"",currentPage()));
     
 } else {
 
     $view_cat->assign("CURRENT_URL",currentPage());
     
 }

 if($config['outofstockPurchase']==1){
     
     $view_cat->assign("BTN_BUY",$lang['front']['viewCat']['buy']);
     $view_cat->assign("PRODUCT_ID",$productResults[$i]['productId']);
     $view_cat->parse("view_cat.productTable.products.buy_btn");
 
 } elseif($productResults[$i]['useStockLevel']==1 && $productResults[$i]['stock_level']>0){
     
     $view_cat->assign("BTN_BUY",$lang['front']['viewCat']['buy']);
     $view_cat->assign("PRODUCT_ID",$productResults[$i]['productId']);
     $view_cat->parse("view_cat.productTable.products.buy_btn");
 
 } elseif($productResults[$i]['useStockLevel']==0){
 
     $view_cat->assign("BTN_BUY",$lang['front']['viewCat']['buy']);
     $view_cat->assign("PRODUCT_ID",$productResults[$i]['productId']);
     $view_cat->parse("view_cat.productTable.products.buy_btn");
 
 }

 $view_cat->assign("BTN_MORE",$lang['front']['viewCat']['more']);
 $view_cat->assign("PRODUCT_ID",$productResults[$i]['productId']);

 if($productResults[$i]['stock_level']<1 && $productResults[$i]['useStockLevel']==1 && $productResults[$i]['digital']==0){
 
     $view_cat->assign("TXT_OUTOFSTOCK",$lang['front']['viewCat']['out_of_stock']);
     
 } else {
 
     $view_cat->assign("TXT_OUTOFSTOCK","");
 
 }
 
 $view_cat->parse("view_cat.productTable.products");
    }
    $view_cat->parse("view_cat.productTable");

} elseif(isset($_GET['searchStr'])) {

    $view_cat->assign("TXT_NO_PRODUCTS",$lang['front']['viewCat']['no_products_match']." ".$_GET['searchStr']);
    $view_cat->parse("view_cat.noProducts");

} else {
    
    $view_cat->assign("TXT_NO_PRODUCTS",$lang['front']['viewCat']['no_prods_in_cat']);
    $view_cat->parse("view_cat.noProducts");

}

$view_cat->parse("view_cat");
$page_content = $view_cat->text("view_cat");
?>
tbladecki
QUOTE
Find:
CODE $view_cat->assign("CATEGORIES",$categoriesData);

After it, add:

CODE$view_cat->assign("TXT_CAT_DESC",$currentCat[0]['cat_desc']);

Find:



I can not find this in the ver 3.0.7, i think that it needs to be modifyed as I belive the code has changed, but Ihave nto been able to get it to work....Please help, I had this on my old version and it worked great!! I have everything else modified and it all apprears to be working fine, I just can not get the info out of the db

Thanks
HempHempHooray!
QUOTE(tbladecki @ Jan 17 2006, 01:04 PM) *
QUOTE
Find:
CODE $view_cat->assign("CATEGORIES",$categoriesData);

After it, add:

CODE$view_cat->assign("TXT_CAT_DESC",$currentCat[0]['cat_desc']);

Find:



I can not find this in the ver 3.0.7, i think that it needs to be modifyed as I belive the code has changed, but Ihave nto been able to get it to work....Please help, I had this on my old version and it worked great!! I have everything else modified and it all apprears to be working fine, I just can not get the info out of the db

Thanks



Same here, can't find that line. All the previous instructions are fine.

I use version 3.0.7 as well.

Any clue?

Thanks in advance.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.