Sidebar Categories Enhancement AddOn

Register an Account
Reply
 
Thread Tools Display Modes
  #21 (permalink)  
Old 09-22-2007, 05:51 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Level 3 is now fully suported:
Just replace original function sidebarExtraCats() in dbtree.php file:

PHP Code:
   //------------------------------------------------------------------------------
       // Function sidebarExtraCats provides information for categories.tpl
       //@param status_mode - it is set in search.php and it can be:
       // all,published or queued.
       //@creator:AnAlienHolakres3-For Pligg Community:Free for use,NO WARRANTY
       // SUBCAT LEVEL 3 FULLY SUPPORTED
       //--------------------------------------------------------------------------------
  
       
function sidebarExtraCats($status_mode) {
       global 
$main_smarty,$db;
        
$root_id=Array();
        
$array tree_to_array(0table_categories);
            
//get array of categories
            
foreach ($array as $cat) {
                
$cat_id[]=$cat['auto_id'];
                
            }     
           
//get array of subcategories 
            
foreach ($array as $subcat) {              
                
$cat_parent[]=$subcat['parent'];
                
            }
              
//get array of roots
               
$roots=$db->get_results("SELECT category_id FROM ".table_categories." WHERE category_parent=0");               
                              
              
//get num of links in root category (and its subcats) (ALL-ALWAYS)
              
foreach ($roots as $roots_id){                
                     
$root_count_array_total[$roots_id->category_id]= 
                     
$db->get_var("SELECT count(link_id) FROM ".table_links." WHERE link_category=".$roots_id->category_id.
                     
" OR link_category IN (SELECT distinct subcat.category_id FROM ".table_categories.
                                            
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.
                                            
".category_id WHERE ".table_categories.".category_id=".$roots_id->category_id.
                                            
" UNION SELECT distinct subcat2.category_id FROM ".table_categories.
                                            
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.".category_id".
                                            
" JOIN ".table_categories." subcat2 ON subcat2.category_parent=subcat.category_id".
                                            
" WHERE ".table_categories.".category_id=".$roots_id->category_id.")");
 
             
//the same,but only PUBLISHED   
                 
if ($status_mode=="published"){          
                      
$root_count_array[$roots_id->category_id]= 
                     
$db->get_var("SELECT count(link_id) FROM ".table_links." WHERE link_status=3 AND (link_category=".$roots_id->category_id.
                     
" OR link_category IN (SELECT distinct subcat.category_id FROM ".table_categories.
                                            
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.
                                            
".category_id WHERE ".table_categories.".category_id=".$roots_id->category_id.
                                            
" UNION SELECT distinct subcat2.category_id FROM ".table_categories.
                                            
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.".category_id".
                                            
" JOIN ".table_categories." subcat2 ON subcat2.category_parent=subcat.category_id".
                                            
" WHERE ".table_categories.".category_id=".$roots_id->category_id."))");
              
             
//the same,but only QUEUED                
                 
}elseif ($status_mode=="queued"){     
                   
$root_count_array[$roots_id->category_id]= 
                     
$db->get_var("SELECT count(link_id) FROM ".table_links." WHERE link_status=2 AND (link_category=".$roots_id->category_id.
                     
" OR link_category IN (SELECT distinct subcat.category_id FROM ".table_categories.
                                            
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.
                                            
".category_id WHERE ".table_categories.".category_id=".$roots_id->category_id.
                                            
" UNION SELECT distinct subcat2.category_id FROM ".table_categories.
                                            
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.".category_id".
                                            
" JOIN ".table_categories." subcat2 ON subcat2.category_parent=subcat.category_id".
                                            
" WHERE ".table_categories.".category_id=".$roots_id->category_id."))");
                 
             
//all   
                 
}else {
                      
$root_count_array=$root_count_array_total;            
              }  
            }   
             
//compare and set root ids with subcats
             
foreach ($cat_id as $category_id){
              foreach (
$cat_parent as $category_parent){
                if (
$category_id && $category_parent) {      
                 if (
$category_id==$category_parent) {      
                   if(!
in_array($category_id,$root_id)) {                   
                   
$root_id[] = $category_id;
                  
                 }
               }
             }        
           }              
       }
       
       
$main_smarty->assign('root_id',$root_id);
       
$main_smarty->assign('links_count_root_array',$root_count_array);
       
$main_smarty->assign('links_count_root_array_total',$root_count_array_total);
          
$main_smarty->assign('extra_sidebar_set',1);
     } 
But if you DO NOT use 3 category levels, i suggest you can keep previous sidebarExtraCats() function which is a little faster.

Of course you can test in on http://vselink.org/098/.
Hope it is all
Reply With Quote
  #22 (permalink)  
Old 09-22-2007, 11:05 AM
not2serious's Avatar
Pligg Donor
Pligg Version: 1.1.5
Pligg Template: Westie
 
Join Date: Apr 2007
Location: East Coast, USA
Posts: 229
Thanks for the great work.

This will be used once I make the upgrade to v9.8 in the next few weeks.
Reply With Quote
  #23 (permalink)  
Old 09-23-2007, 11:14 AM
New Pligger
 
Join Date: Sep 2007
Posts: 2
i have 9.8.1 and i tryed this code i don't know if i missed something or want but it would not show my cats. is it possible to ask for a .zip file with the changes.

Thanks
Reply With Quote
  #24 (permalink)  
Old 09-23-2007, 01:15 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Have you downloaded the icons from here (http://forums.pligg.com/pligg-tutori...html#post39806) and set the paths correctly?
Reply With Quote
  #25 (permalink)  
Old 09-23-2007, 02:34 PM
New Pligger
 
Join Date: Sep 2007
Posts: 6
I have 9.8, did exactly per above post, but I dont see how to add the sub-category under Admin/Category Management..it appears same as before.

Also, I see two passive boxes between each of the categories..is this normal ?

Thanks in advance...
Reply With Quote
  #26 (permalink)  
Old 09-23-2007, 03:45 PM
New Pligger
 
Join Date: Sep 2007
Posts: 6
Quote:
Originally Posted by plador View Post
I have 9.8, did exactly per above post, but I dont see how to add the sub-category under Admin/Category Management..it appears same as before.

Also, I see two passive boxes between each of the categories..is this normal ?

Thanks in advance...
pl ignore...didnt see the latest update...will try that out...
Reply With Quote
  #27 (permalink)  
Old 09-23-2007, 03:53 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Yankidank crated excellent video tutorial for Categories,just look at it,its in tutorials section:
http://forums.pligg.com/pligg-tutori...-tutorial.html
Reply With Quote
  #28 (permalink)  
Old 09-23-2007, 04:13 PM
New Pligger
 
Join Date: Sep 2007
Posts: 6
Quote:
Originally Posted by AnAlienHolakres3 View Post
Yankidank crated excellent video tutorial for Categories,just look at it,its in tutorials section:
http://forums.pligg.com/pligg-tutori...-tutorial.html
Ok got it all to work...was breaking my head on how to make a sub-category, then discovered the drag and drop while playing around Ill take a look at the video when I get the chance...for now I want to toy around with this

Very nice work, and thanks for making our lives easier !

By the way, is there a limit to the number of levels in the sub category ??
I understood from your posts that you had last enabled Level 3, but it looks like there is no limit ? I could add upto 5 sub levels
If this is true, thats great !!
Reply With Quote
  #29 (permalink)  
Old 09-23-2007, 04:50 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Appearance can be deceiving. More than 3 levels will result in wrong subcategories links count. But if you need more levels, for example 10 and many categories,it is possible to do something special for your needs. But some Pligg donation would be necessary...
Reply With Quote
  #30 (permalink)  
Old 09-23-2007, 05:08 PM
New Pligger
 
Join Date: Sep 2007
Posts: 6
Quote:
Originally Posted by AnAlienHolakres3 View Post
Appearance can be deceiving. More than 3 levels will result in wrong subcategories links count. But if you need more levels, for example 10 and many categories,it is possible to do something special for your needs. But some Pligg donation would be necessary...
I agree...

With that in mind, is there any easy way to duplicate subcategories to sibling categories ?
I haven't looked too deep, but are they stored in the database or an xml file ?
Xml would be terrific as we can directly edit the file...
(Since there is only a 'create/delete category' option...)
edit: ok i see its in the database...darn

So I understand this 'feature' is only an add-on and may/may not be implemented/supported in future releases ?

I feel this addon will be a major selling point and you must beef it up and modularize it so it can seamlessly work between upgrades...(at a cost of coz)

Is there any mechanism by which users can contribute customized code ?

Last edited by plador; 09-23-2007 at 06:09 PM.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wistie Move Categories to Sidebar w/RSS MissDanni Questions and Comments 0 07-31-2009 10:33 AM
Beta 9.9.5- Bug in Categories & Latest comments sidebar modules kallu Questions and Comments 3 08-07-2008 08:28 AM
How to start with sidebar categories closed? longcountdown Questions and Comments 0 02-15-2008 01:16 PM
Alphabetize Sidebar Categories shackbase Questions and Comments 2 11-16-2007 07:56 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development