Support Forums

MODIFICATION sub Category level 2

This is a discussion on MODIFICATION sub Category level 2 within the Modules / Plugins / Modifications forums, part of the Developer Forums category; Before I ad this modification to the Module Release I need some help to finish it. I made a change ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 08-18-2008, 04:29 PM   #1
Customer
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 285
Rep Power: 20
hel68c is just really nice hel68c is just really nice
Default MODIFICATION sub Category level 2

Before I ad this modification to the Module Release I need some help to finish it.

I made a change in the function getSubCategoriesList in the /includes/classes/kernel/categories.php to display level 2 sub category. It work fine except I can't get the total of ads for each subs categories.

I tried with the function get_count($arr_ids) but I can't manage how to code it.

Do you have some hint ?

Here is what it look like:

R/C (Radio Control) R/C (Radio Control) (6)
->Aerial Photography () <-- Can't get the total of ads
->Aircrafts () <-- Can't get the total of ads
->->Airplanes electric (0) <-- Can't get the total of ads
->->Airplanes fuel (0)
->->Helicopters (0)
->->Jets electric (0)
->->Jets fuel & Turbine (0)
->Boats ()
->->Electrics (0)
->->Fuels (0)
->Cars & Trucks ()
->->Electrics (0)
->->Fuels (0)
->Electric Power Systems ()
->Electronics ()
->->Accessories (0)
->->Chargers (0)
->->Radios (0)
->->Receivers (0)
->->Servos (0)
->Fuel Engines & accessories ()
->->Accessories (0)
->->Engines (0)
->->Mufflers (0)
->Miscellaneous ()
->Model Building Supplies ()
->Motorcycles ()
->Tanks & Tractors ()


Quote:
function getSubCategoriesList($parent, $limit=20)
{
global $db;
$add_cats='';
$sSQL2 = "SELECT id,name,slug,image,cLink FROM ".PREFIX."categories WHERE parent_id = ".$parent." AND display<>'N' ORDER BY cORDER DESC, name ASC LIMIT ".$limit;
$result2=$db->query($sSQL2);
$i=0;
while($rs=$result2->fetch())
{
if($rs['cLink']<>"")
{
$add_cats.='<a href="'.$rs['cLink'].'">'.htmlspecialchars($rs['name']).'</a> ';
}
else
{

/* Begin level 2 sub category */

$parent2=$rs['id'];
$add_cats2='';
$sSQL3 = "SELECT id,name,slug,image,cLink FROM ".PREFIX."categories WHERE parent_id = ".$parent2." AND display<>'N' ORDER BY cORDER DESC, name ASC LIMIT ".$limit;
$result3=$db->query($sSQL3);

while($rs1=$result3->fetch())
{
if($rs1['cLink']<>"")
{
$add_cats2.='<a href="'.$rs1['cLink'].'">'.htmlspecialchars($rs1['name']).'</a> ';
}
else
{
$arr_childs = array($rs['id']);
$this->get_ids($arr_childs);
$cat_count=$this->get_count($arr_childs);
$slug = ( empty($rs['slug']) ) ? $rs1['id']: $rs1['slug'];

$add_cats2.='->->'.'<a href="category.php?cat='.$slug.'">'.htmlspecialcha rs($rs1['name']).' ('.$cat_count.')'.'</a> <br />';
}

}
if($add_cats2=="")
{
$sub2=htmlspecialchars($rs1['description']);
}
else
{
$sub2='<div class="small">'.$add_cats2 . LANG_DOT_DOT_DOT.'</div>';
}

/* End level 2 sub category */

}

if($Core->settings['showTotal']=='Y')
{
$arr_childs = array($rs['id']);
$this->get_ids($arr_childs);
$cat[$i]['total']=$this->get_count($arr_childs);

}

$add_cats.='->'.'<a href="category.php?cat='.$slug.'">'.htmlspecialcha rs($rs['name'])." (".$total.")".'</a> <br />'.$add_cats2;

$i++;


}
if($add_cats=="")
{
$sub=htmlspecialchars($rs['description']);
}
else
{
$sub='<div class="small">'.$add_cats . LANG_DOT_DOT_DOT.'</div>';
}
return $sub;
}
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)
hel68c is offline   Reply With Quote
Old 08-18-2008, 10:42 PM   #2
Customer
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 285
Rep Power: 20
hel68c is just really nice hel68c is just really nice
Default

I only get the total of individual category.

I'm trying to get the total of the category like this:

Aircrafts
->Airplanes(2)
->ads
->ads

->->airplane acc.(2)
->->ads
->->ads

->Helicopters(2)
->->ads
->->ads



Now I get:

Aircrafts(6)
->Airplanes()
->ads
->ads

->->airplane acc.(2)
->->ads
->->ads

->Helicopters()
->->ads
->->ads
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)
hel68c is offline   Reply With Quote
Old 08-19-2008, 03:06 PM   #3
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 133
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Hi,

First off I would create a new smarty plugin for this instead of altering the Categories.php file. That way upgrades will not be affected.

Once you have done that I think this line may be the problem:
PHP Code:
                    $arr_childs = array($rs['id']); 
                    
$this->get_ids($arr_childs); 
For the second depth change the $arr_childs variable to something else just incase they are clashing.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 08-20-2008, 09:33 PM   #4
Customer
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 285
Rep Power: 20
hel68c is just really nice hel68c is just really nice
Default

Allo Eric,

HTML Code:
First off I would create a new smarty plugin for this instead of altering the Categories.php file. That way upgrades will not be affected.
Can you explain how to create a smarty plugin?
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)
hel68c is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modification: RSS Feeds by Category (or anything else) jonahcoyote Modules / Plugins / Modifications 20 06-19-2009 01:16 PM
Accounts... doc1975 Pre Sales Questions 2 09-08-2006 02:48 PM


All times are GMT -4. The time now is 10:50 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0