Sidebar Categories Enhancement AddOn

Register an Account
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old 09-19-2007, 01:46 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
This version provides more functionality:
1) if you select subcategory then subcategories of specific root category are shown even when you reload the page
2) every selected category/subcategory is highlighted


Steps to do:
1) Open search.php in your libs folder.
Find following code:
PHP Code:
       //should we filter to just this category?
        
if(isset($this->category))
        {
            
//$catId = $db->get_var("SELECT category_id from " . table_categories . " where category_name = '" . $this->category . "';");
            
$catId get_category_id($this->category);
            if(isset(
$catId)){
                
$child_cats ''
Then Add this code after it:
PHP Code:
                //===========categories ADDON-AnALienHolakres3                                  
                   
$selected_root_id $db->get_var("SELECT category_parent FROM " table_categories " WHERE `category_id` = " .  $catId); 
                    
$main_smarty->assign('selected_root_id',$selected_root_id);   
                    
$main_smarty->assign('selected_cat_id',$catId);      
                
//============addon END 
2) If you have Pligg version 9.7 replace all code in categories.tpl (templates/template/sidebar modules folder) with:
PHP Code:
    {php}  

  
       function 
set_root_smart() {
       global 
$main_smarty;
        
$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'];
                
            }   
             
//compare and set root ids  
             
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);
       return 
$root_id;
     }
     
     
set_root_smart(); 
     
   {/
php}   
   
   
<
div class="tlb">
    {
php}
        echo 
"<span><a onclick=\"new Effect.toggle('cats','blind', {queue: 'end'}); \"> <img src=\"".my_pligg_base."/templates/".The_Template."/images/expand.png\"></a></span>";
    {/
php}
    <
a href="#">{#PLIGG_Visual_Category_Title#}</a>
</div>

<
div id="cats" style="padding-bottom:1px">
    <
ul class="nav-secondary">  
        {
section name=thecat loop=$cat_array start=1}

            {if 
$cat_array[thecat].spacercount lt $lastspacer}{$cat_array[thecat].spacerdiff|repeat_count:'</ul>''</div>'}{/if}
            {if 
$cat_array[thecat].spacercount gt $lastspacer}<ul>{/if}

            <
a href="{$URL_rsscategory, $cat_array[thecat].auto_id}" target="_blank" style="border:none;">      
            <
img src="{$my_pligg_base}/templates/{$the_template}/images/rss.gif" border="0" style="float:right;padding-right:7px;"></a>
                    
                        
                        {
section name=root2 loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root2]}   
                        
                                {if 
$root_id[root2neq $selected_root_id}  
                       <
img id="picroot{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                        
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                       <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;display:none;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                        
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                                {else}
                                 <
img id="picroot{$cat_array[thecat].auto_id}"style="display:none;float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                                 
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                                <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                                
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'">           
                                  
                                {/if}
                          
                          
                          {/if}                                     
                          {/
section}   
                        
                            
            
                    {if 
$pagename eq "published"
                       
                        {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_idstyle="display:none"{/if}>   
                        {
assign var=root_category value=$cat_array[thecat].auto_id}      
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}  
                         <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $cat_array[thecat].auto_id eq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a>  
                         {/if}
                      
                     
                        {else}  
                        
                        {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_id}style="display:none"{/if}>   
                        {
assign var=root_category value=$cat_array[thecat].auto_id}      
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}  
                         <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $cat_array[thecat].auto_id  eq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a>  
                         {/if}
                        
                  
                        {/if}
               
                                                   
                    
                    
                    
                    </
li>      
            
            {
assign var=lastspacer value=$cat_array[thecat].spacercount}
        {/
section}
    </
ul>
</
div
If you use latest Pligg version (0.98) please read next post.
Reply With Quote
  #12 (permalink)  
Old 09-19-2007, 01:48 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
f you use Pligg Version 9.8 there is UPDATED and FIXED code (yeah, I have discovered the problem so if somebody could test it and give me some feedback I would appreciate that.
PHP Code:
{php}  
//********************************************************************************************
// This file is for VERSION 0.98 ONLY!. (categories.tpl)
//Customized by AnAlienHolakres3 for Pligg Comunity. No warranty,Free of charge
// If you like it you can always make your own tut for the rest of us
//********************************************************************************************
       
function set_root_smart() {
       global 
$main_smarty;
        
$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'];
                
            }   
             
//compare and set root ids  
             
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);
       return 
$root_id;
     }
     
     
set_root_smart(); 
     
   {/
php}  
<
div class="tlb">
    {
php}
        echo 
"<span><a onclick=\"new Effect.toggle('cats','blind', {queue: 'end'}); \"> <img src=\"".my_pligg_base."/templates/".The_Template."/images/expand.png\" alt=\"expand\" /></a></span>";
    {/
php}
    <
a href="#">{#PLIGG_Visual_Category_Title#}</a>
</div>

<
div id="cats" style="padding-bottom:1px">
    <
ul id="nav-secondary">
        <
li>
            {
section name=thecat loop=$cat_array start=1}
                {if 
$lastspacer eq ""}
               
                    {
assign var=lastspacer value=$cat_array[thecat].spacercount}
                {/if}

                {if 
$cat_array[thecat].spacercount lt $lastspacer}{$cat_array[thecat].spacerdiff|repeat_count:'</li></ul></div>'}{/if}
                {if 
$cat_array[thecat].spacercount gt $lastspacer}<ul style="padding-left:12px"><li>{/if}

                <
a href="{$URL_rsscategory, $cat_array[thecat].auto_id}" target="_blank" style="border:none;">      
                <
img src="{$my_pligg_base}/templates/{$the_template}/images/rss.gif" border="0" style="float:right;padding-right:10px;" alt="RSS" /></a>
                
                        {
section name=root2 loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root2]}   
                          
                                        {if 
$root_id[root2neq $selected_root_id}  
                                          <
img id="picroot{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                                             
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                                           <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;display:none;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                                                
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                                    {else}
                                           <
img id="picroot{$cat_array[thecat].auto_id}"style="display:none;float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                                                
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                                         <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                                              
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'">           
                                  
                                      {/if}
                        
                        
                          {/if}                                     
                          {/
section}  
                
                
        
                {if 
$pagename eq "published"}
                
                    {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_idstyle="display:none"{/if}>   
                        {
assign var=root_category value=$cat_array[thecat].auto_id}      
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}  
                         <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a>  
                         {/if}
                
                
                
    
                {else}
                     {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_idstyle="display:none"{/if}>   
                        {
assign var=root_category value=$cat_array[thecat].auto_id}      
                        {/if}                       
                        {/
section
                        
                        {if 
$cat_array[thecat].auto_id neq $root_category}  
                         <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}</a>  
                         {/if}                                                                                                                  
                    
                    
                {/if}
    
                {
assign var=lastspacer value=$cat_array[thecat].spacercount}
            {/
section}
        </
li>
    </
ul>
</
div
Reply With Quote
  #13 (permalink)  
Old 09-20-2007, 12:55 PM
Constant Pligger/Designer
Pligg Version: 1.0
Pligg Template: silverbullet
 
Join Date: Mar 2007
Posts: 147
Send a message via MSN to skins4webs
Great Job on this Modification.. Here is the result in 9.8 when you replace the categories with your updated code.

/class.template.php(745

: eval()'d code on line 219
Reply With Quote
  #14 (permalink)  
Old 09-20-2007, 07:17 PM
not2serious's Avatar
Pligg Donor
Pligg Version: 1.1.5
Pligg Template: Westie
 
Join Date: Apr 2007
Location: East Coast, USA
Posts: 229
I have been following your posts for the Sidebar Categories AddOn. I hope to utilize your modifications when I upgrade from 9.6 to 9.8. There was an additional operation that I wanted to have for the Categories. I will show and then explain.

Categories
Category 1 (21 / 121)
Category 2 (12 / 54)
Category 3 (5 / 25)

The category description is the same as currently utilized. Followed by two integers (with or without brackets and separated by back slash or other). The first integer would be the total of stories in that category and in “Published” or “Upcoming.” The second integer would be the total site stories in the given category.

Why? I believe this would give a visitor additional stimulation to explore additional stories of that category and/or post to the category. This would be a good mod to encourage additional site activity. Just like the vote totals that are now listed in the sidebar.

Unfortunately, I do not have the skills to do the coding. Nor, do I have the knowledge to realize if this can be accomplished with reasonable effort. Therefore, I submit this ideas to you for your consideration. Clearly, you have the skills to accomplish this task, and since you have been working on this section of the application, I thought you may consider this mod.

Feel free to ask me any questions on this idea. I have sent this to you as a private message because I do not want to expose this to the community and have undue pressure fore its development.

Thanks for your great work for the community.
Reply With Quote
  #15 (permalink)  
Old 09-21-2007, 06:30 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
I have done it. Version 0.3 can be considered more as a module than simple dirty tutorial. Most of PHP code from smarty file was removed (it was too ugly and there could be possible security problem).

Overal features:
+ Subcategories are automatically hidden
+ Support up to LEVEL 2
+ Memory for selected category->is shown
+ Link category count exactly as not2serious demanded for root categories
+ Support Pligg v 0.97 and v 0.98
+ Tested and bugfree (hopefully

You can see and try the demo (v 0.98) on http://vselink.org/098/.

Required files::
Only icons:
Copy them in your yget/images folder:
scroll_down.ico:
scroll_down_hover.ico:
scroll_up.ico:
scroll_up_hover.ico:

Files modification::
1) open your search.php in your /libs/ folder
1.1 search for if ($this->filterToStatus == 'all') and change the whole paragraph as following:
PHP Code:
if ($this->filterToStatus == 'all') {$from_where .= " link_status!='discard' ";sidebarExtraCats('all');}
        if (
$this->filterToStatus == 'queued') {$from_where .= " link_status='queued' ";sidebarExtraCats('queued');}
        if (
$this->filterToStatus == 'discard') {$from_where .= " link_status='discard' ";}        
        if (
$this->filterToStatus == 'published') {$from_where .= " link_status='published' ";sidebarExtraCats('published');  }        
        if (
$this->filterToStatus == 'popular') {$from_where .= " link_status='published' ";} 
1.2 still in this file,find following CODE:
PHP Code:
    //should we filter to just this category?
        
if(isset($this->category))
        {
            
//$catId = $db->get_var("SELECT category_id from " . table_categories . " where category_name = '" . $this->category . "';");
            
$catId get_category_id($this->category);
            if(isset(
$catId)){
                
$child_cats ''
and after that add this code:
PHP Code:
                //===========categories ADDON-AnALienHolakres3                                  
                   
$selected_root_id $db->get_var("SELECT category_parent FROM " table_categories " WHERE `category_id` = " .  $catId); 
                   
$selected_root_id_l2=$db->get_var("SELECT category_parent FROM " table_categories " WHERE `category_id` = ".$selected_root_id);
 
                   if (
$selected_root_id_l2>0) {
                    
$main_smarty->assign('selected_root_id_l2',$selected_root_id_l2);   
                   }
                    
$main_smarty->assign('selected_root_id',$selected_root_id);   
                    
$main_smarty->assign('selected_cat_id',$catId);      
                
//============addon END 
You can save it.
2) Open dbtree.php file in your /libs/ folder.
2.1 Just add this function (i preffer to end):
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
       //--------------------------------------------------------------------------------
  
       
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_categories." LEFT JOIN ".table_links." ON ".table_links.".link_category=".table_categories.
                     
".category_id WHERE category_id=".$roots_id->category_id." OR category_parent=".$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_categories
                       
" LEFT JOIN ".table_links." ON ".table_links.".link_category=".table_categories.
                       
".category_id WHERE (category_id=".$roots_id->category_id." OR category_parent=".$roots_id->category_id") AND link_status=3");
              
             
//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_categories.
                     
" LEFT JOIN ".table_links" ON ".table_links.".link_category=".table_categories.
                     
".category_id WHERE (category_id=".$roots_id->category_id." OR category_parent=".$roots_id->category_id") AND link_status=2");   
                 
             
//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);
     } 
You can save it. Follow next post.
Reply With Quote
  #16 (permalink)  
Old 09-21-2007, 06:33 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
3) Replace all code in your categories.tpl file.
Version 0.97:
PHP Code:
{if $extra_sidebar_set neq 1}
{
php}
//this is necessary bc search.php is not alwasys used  and when we click on for example top users and then on category,UPCOMING(queued)links are shown
sidebarExtraCats('queued');{/php}
{/if}   
   
   
<
div class="tlb">
    {
php}
        echo 
"<span><a onclick=\"new Effect.toggle('cats','blind', {queue: 'end'}); \"> <img src=\"".my_pligg_base."/templates/".The_Template."/images/expand.png\"></a></span>";
    {/
php}
    <
a href="#">{#PLIGG_Visual_Category_Title#}</a>
</div>

<
div id="cats" style="padding-bottom:1px">
    <
ul class="nav-secondary">  
        {
section name=thecat loop=$cat_array start=1}
                   
            {if 
$cat_array[thecat].spacercount lt $lastspacer}{$cat_array[thecat].spacerdiff|repeat_count:'</ul>''</div>'}
            {
php}$count=0; {/php}{/if}
            {if 
$cat_array[thecat].spacercount gt $lastspacer}<ul>{/if}

            <
a href="{$URL_rsscategory, $cat_array[thecat].auto_id}" target="_blank" style="border:none;">      
            <
img src="{$my_pligg_base}/templates/{$the_template}/images/rss.gif" border="0" style="float:right;padding-right:7px;"></a>
                    
                        
                        {
section name=root2 loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root2]}   
                        
                                {if 
$root_id[root2neq $selected_root_id}  
                       <
img id="picroot{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                        
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                       <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;display:none;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                        
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                                {else}
                                 <
img id="picroot{$cat_array[thecat].auto_id}"style="display:none;float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                                 
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                                <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                                
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'">           
                                  
                                {/if}
                          
                          
                          {/if}                                     
                          {/
section}   
                        
                            
            
                    {if 
$pagename eq "published"
                                                                                                                                                                                                                                       
                        {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name
                        {
assign var=root_category value=$cat_array[thecat].auto_id}        
                         {if 
$links_count_root_array[$root_categoryneq ""}<span class="cat_stat">[{$links_count_root_array[$root_category]}/{$links_count_root_array_total[$root_category]}]</span>{/if}</a
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_id}{if $root_id[rootneq $selected_root_id_l2style="display:none"{/if}{/if}>   
                        
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}
                        {
assign var=normal_cat value=$cat_array[thecat].auto_id}        
                         <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $cat_array[thecat].auto_id eq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}  
                         {if 
$links_count_root_array[$normal_catneq ""}<span class="cat_stat">[{$links_count_root_array[$normal_cat]}/{$links_count_root_array_total[$normal_cat]}]</span>{/if} </a>  
                         {/if}
                      
                     
                        {else}  
                        
                        {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}
                        {
assign var=root_category value=$cat_array[thecat].auto_id}  
                          {if 
$links_count_root_array[$root_categoryneq ""}<span class="cat_stat">[{$links_count_root_array[$root_category]}/{$links_count_root_array_total[$root_category]}]</span>{/if} </a
                        
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_id}{if $root_id[rootneq $selected_root_id_l2style="display:none"{/if}{/if}>   
                         
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}  
                        {
assign var=normal_cat value=$cat_array[thecat].auto_id}        
                         <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $cat_array[thecat].auto_id  eq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}
                          {if 
$links_count_root_array[$normal_catneq ""}<span class="cat_stat">[{$links_count_root_array[$normal_cat]}/{$links_count_root_array_total[$normal_cat]}]</span>{/if} </a>  
                         {/if}
                        
                  
                        {/if}
               
                                                   
                    
                    
                    
                    </
li>      
            
            {
assign var=lastspacer value=$cat_array[thecat].spacercount}
        {/
section}
    </
ul>
</
div
Reply With Quote
  #17 (permalink)  
Old 09-21-2007, 06:35 PM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
Version 0.98
PHP Code:
{if $extra_sidebar_set neq 1}
{
php}
//this is necessary bc search.php is not alwasys used  and when we click on for example top users and then on category,UPCOMING(queued)links are shown
sidebarExtraCats('queued');{/php}
{/if}

<
div class="tlb">
    {
php}        
        echo 
"<span><a onclick=\"new Effect.toggle('cats','blind', {queue: 'end'}); \"> <img src=\"".my_pligg_base."/templates/".The_Template."/images/expand.png\" alt=\"expand\" /></a></span>";
    {/
php}
    <
a href="#">{#PLIGG_Visual_Category_Title#}</a>
</div>

<
div id="cats" style="padding-bottom:1px">
    <
ul id="nav-secondary">
        <
li>
            {
section name=thecat loop=$cat_array start=1}
                {if 
$lastspacer eq ""}
                    {
assign var=lastspacer value=$cat_array[thecat].spacercount}
                {/if}

                {if 
$cat_array[thecat].spacercount lt $lastspacer}{$cat_array[thecat].spacerdiff|repeat_count:'</li></ul></div>'}{/if}
                {if 
$cat_array[thecat].spacercount gt $lastspacer}<ul style="padding-left:12px"><li>{/if}

                <
a href="{$URL_rsscategory, $cat_array[thecat].auto_id}" target="_blank" style="border:none;">      
                <
img src="{$my_pligg_base}/templates/{$the_template}/images/rss.gif" border="0" style="float:right;padding-right:10px;" alt="RSS" /></a>
                
                        {
section name=root2 loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root2]}   
                          
                                        {if 
$root_id[root2neq $selected_root_id}    
                                          <
img id="picroot{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                                             
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                                           <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;display:none;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                                                
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                                    {else}
                                           <
img id="picroot{$cat_array[thecat].auto_id}"style="display:none;float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_down.ico" width="18" height="14" 
                                                
onmouseover="this.src='../templates/yget/images/scroll_down_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_down.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='';document.getElementById('picrootU{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'"
                       
                                         <
img id="picrootU{$cat_array[thecat].auto_id}"style="float:right;padding-right:7px;margin-top:1px;width:18px;height:14px" src="../templates/yget/images/scroll_up.ico" width="18" height="14" 
                                              
onmouseover="this.src='../templates/yget/images/scroll_up_hover.ico';this.width='18';this.height='14'" onmouseout="this.src='../templates/yget/images/scroll_up.ico';this.width='18';this.height='14'" onmousedown="document.getElementById('subcat{$cat_array[thecat].auto_id}').style.display='none';document.getElementById('picroot{$cat_array[thecat].auto_id}').style.display='';this.style.display='none'">           
                                  
                                      {/if}
                        
                        
                          {/if}                                     
                          {/
section}  
                
                                   
        
               {if 
$pagename eq "published"
                                                                                                                                                                                                                                       
                        {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name
                        {
assign var=root_category value=$cat_array[thecat].auto_id}        
                         {if 
$links_count_root_array[$root_categoryneq ""}<span class="cat_stat">[{$links_count_root_array[$root_category]}/{$links_count_root_array_total[$root_category]}]</span>{/if}</a
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_id}{if $root_id[rootneq $selected_root_id_l2}  style="display:none"{/if}{/if}>   
                        
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}
                        {
assign var=normal_cat value=$cat_array[thecat].auto_id}        
                         <
a href="{$URL_maincategory, $cat_array[thecat].safename}" style={if $cat_array[thecat].auto_id eq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}  
                         {if 
$links_count_root_array[$normal_catneq ""}<span class="cat_stat">[{$links_count_root_array[$normal_cat]}/{$links_count_root_array_total[$normal_cat]}]</span>{/if} </a>  
                         {/if}
                      
                     
                        {else}  
                        
                        {
section name=root loop=$root_id start=0}
                        {if 
$cat_array[thecat].auto_id eq $root_id[root]}                                                                                                
                        <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $root_id[rooteq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}
                        {
assign var=root_category value=$cat_array[thecat].auto_id}  
                          {if 
$links_count_root_array[$root_categoryneq ""}<span class="cat_stat">[{$links_count_root_array[$root_category]}/{$links_count_root_array_total[$root_category]}]</span>{/if} </a
                        
                        <
div id="subcat{$cat_array[thecat].auto_id}" {if $root_id[rootneq $selected_root_id}{if $root_id[rootneq $selected_root_id_l2style="display:none"{/if}{/if}>   
                         
                        {/if}                       
                        {/
section}  
                        
             
                        {if 
$cat_array[thecat].auto_id neq $root_category}  
                        {
assign var=normal_cat value=$cat_array[thecat].auto_id}        
                         <
a href="{$URL_queuedcategory, $cat_array[thecat].safename}" style={if $cat_array[thecat].auto_id  eq $selected_cat_id}"font-weight:bold;padding-bottom:5px;color:#0033e3"{else}"padding-bottom:5px;"{/if}>{$cat_array[thecat].name}
                          {if 
$links_count_root_array[$normal_catneq ""}<span class="cat_stat">[{$links_count_root_array[$normal_cat]}/{$links_count_root_array_total[$normal_cat]}]</span>{/if} </a>  
                         {/if}
                        
                  
                        {/if}
    
                {
assign var=lastspacer value=$cat_array[thecat].spacercount}
            {/
section}
        </
li>
    </
ul>
</
div
Ok. You can save it.
4) If you want, you can add this class to your main.css file in templates folder:
Code:
/* Sidebar Category Stats */
.cat_stat{ color: #6FB7FF }
Thats it. This is my final release of this addon. Hope it helps
Reply With Quote
  #18 (permalink)  
Old 09-21-2007, 10:45 PM
Constant Pligger/Designer
Pligg Version: 1.0
Pligg Template: silverbullet
 
Join Date: Mar 2007
Posts: 147
Send a message via MSN to skins4webs
Great Job

Very useful!
Reply With Quote
  #19 (permalink)  
Old 09-21-2007, 11:10 PM
not2serious's Avatar
Pligg Donor
Pligg Version: 1.1.5
Pligg Template: Westie
 
Join Date: Apr 2007
Location: East Coast, USA
Posts: 229
I have noticed a small issue with the totals for the Categories (the right number).

Categories
Category 1 (21 / 121)
Category 2 (12 / 54)
Category 3 (5 / 25)


This total in your demo does not count (include) the posts in the sub-categories. If you look at your demo, 'Upcoming" and "apples" the total "3" does not include the post in the sub-category "big." The total for the "apple" category shoud be "4".

The category in the story summary states "normal big." I would expect this value to be "apple big." Unless, I missed something, of course.
Reply With Quote
  #20 (permalink)  
Old 09-22-2007, 03:11 AM
AnAlienHolakres3's Avatar
Pligg Donor/Coder
 
Join Date: Jul 2007
Location: Prague
Posts: 116
Send a message via ICQ to AnAlienHolakres3
You are partially right. Links in subcategories at LEVEL 2 are not included. However, link in subcats at LEVEL 1 are counted. So if you dont plan use subcategories at LEVEL 2 there is no problem at all.

But one way or another there is a bug with level 3, i am working on it,it is not so easy:/
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