Go Back   Pligg Forum > Pligg Help > Pligg Tutorials
Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 09-22-2007, 03:51 AM
AnAlienHolakres3's Avatar
AnAlienHolakres3 AnAlienHolakres3 is offline
Send a message via ICQ to AnAlienHolakres3
Pligg Developer
 
Join Date: Jul 2007
Location: Prague
Posts: 117
Downloads: 24
Uploads: 1
Thanks: 7
Thanked 111 Times in 40 Posts
Sidebar Categories AddOn: v.0.35 FINAL

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
__________________
=Everything that has a beginnig has an end=
=Nevere stop fighting=

Site: http://www.vselink.org
Reply With Quote
The Following User Says Thank You to AnAlienHolakres3 For This Useful Post:
Sponsored Links
Check out the New Templates at the Pligg Pro Shop.
  #22 (permalink)  
Old 09-22-2007, 09:05 AM
not2serious's Avatar
not2serious not2serious is offline
Pligg Donor
Pligg Version: v0.96 w/modifications
Pligg Template: Yget w/modifications
 
Join Date: Apr 2007
Location: East Coast, USA
Posts: 226
Downloads: 29
Uploads: 0
Thanks: 16
Thanked 16 Times in 15 Posts
Thanks for the great work.

This will be used once I make the upgrade to v9.8 in the next few weeks.
__________________
My Pligg Site: Critique My Art
My Arts Directory: Links 2 Arts
Reply With Quote
  #23 (permalink)  
Old 09-23-2007, 09:14 AM
russellharrower russellharrower is offline
New Pligger
 
Join Date: Sep 2007
Posts: 2
Downloads: 2
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
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, 11:15 AM
tbones tbones is offline
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,073
Downloads: 26
Uploads: 0
Thanks: 53
Thanked 25 Times in 23 Posts
Have you downloaded the icons from here (Sidebar Categories Enhancement AddOn) and set the paths correctly?
Reply With Quote
  #25 (permalink)  
Old 09-23-2007, 12:34 PM
plador plador is offline
New Pligger
 
Join Date: Sep 2007
Posts: 6
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
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, 01:45 PM
plador plador is offline
New Pligger
 
Join Date: Sep 2007
Posts: 6
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
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, 01:53 PM
AnAlienHolakres3's Avatar
AnAlienHolakres3 AnAlienHolakres3 is offline
Send a message via ICQ to AnAlienHolakres3
Pligg Developer
 
Join Date: Jul 2007
Location: Prague
Posts: 117
Downloads: 24
Uploads: 1
Thanks: 7
Thanked 111 Times in 40 Posts
How to add a subcategory

Yankidank crated excellent video tutorial for Categories,just look at it,its in tutorials section:
Category Management Tutorial
__________________
=Everything that has a beginnig has an end=
=Nevere stop fighting=

Site: http://www.vselink.org
Reply With Quote
  #28 (permalink)  
Old 09-23-2007, 02:13 PM
plador plador is offline
New Pligger
 
Join Date: Sep 2007
Posts: 6
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Excellent work !!

Quote:
Originally Posted by AnAlienHolakres3 View Post
Yankidank crated excellent video tutorial for Categories,just look at it,its in tutorials section:
Category Management Tutorial
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, 02:50 PM
AnAlienHolakres3's Avatar
AnAlienHolakres3 AnAlienHolakres3 is offline
Send a message via ICQ to AnAlienHolakres3
Pligg Developer
 
Join Date: Jul 2007
Location: Prague
Posts: 117
Downloads: 24
Uploads: 1
Thanks: 7
Thanked 111 Times in 40 Posts
How many levels supported:

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...
__________________
=Everything that has a beginnig has an end=
=Nevere stop fighting=

Site: http://www.vselink.org
Reply With Quote
  #30 (permalink)  
Old 09-23-2007, 03:08 PM
plador plador is offline
New Pligger
 
Join Date: Sep 2007
Posts: 6
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
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 04:09 PM.
Reply With Quote
Reply



Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make sub categories? knut General Help 9 02-23-2008 05:57 AM
Left and right sidebar for Pligg 9.6 JPR75 Pligg Templates 2 12-20-2007 04:25 PM
categories not working grimusm General Help 5 11-30-2007 03:58 AM
Sidebar Categories fabben Bug Report 1 10-10-2006 08:30 AM
Working with categories jacknoir Installation and Upgrade Help 5 07-29-2006 01:47 PM


LinkBacks Enabled by vBSEO 3.0.0