phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

[RC] Categories Collapse to Top
1 members found this topic helpful

 
Search this topic... | Search MOD Development... | Search Box
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Author Message
Murmur
Board Member



Joined: 20 Aug 2009

Posts: 57
Location: California


flag
PostPosted: Fri Aug 28, 2009 7:32 am 
Post subject: Categories Collapse to Top

This is a simple mod that works in conjunction with phpBB 2.0.23's default forum category collapse behavior.

A couple of the design goals in my own project are:

1) maximize real estate
2) anchor the screen to minimize 'jumpiness' in page transitions

To this end placing important info near the page top when ever possible is always kept in mind.

When the forum categories are 'collapsed' this mod moves the open category to the top of the list of categories. That's it.

The mod may or may not work with other category collapse/rollout mods.

If it has already been done, we can delete this post. If there's a better way to code it, I'm all ears.



Code:

#################################################################
## MOD Title: Categories Collapse to Top
## MOD Version: .99
## MOD Author: Murmur (Mike McKeown)
## MOD Description:
##      When in the collapsed categories view, this mod
##      moves the open category to the top of the list
##      of categories.
##
## Installation Level:   Easy
## Installation Time:   1-2 Minutes
## Files To Edit (1): index.php
## Added queries: 0
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]---------------------------------------------
#
index.php

#
#-----[ FIND ]---------------------------------------------
# around line 130

if( ( $total_categories = count($category_rows) ) )
{

#
#-----[ AFTER, ADD ]---------------------------------------
#

  if($viewcat != -1) {
      for ($i = 0; $i < $total_categories; $i++ ) {
          if($viewcat == $category_rows[$i]['cat_id']) {
              $category_rows[$i]['cat_order'] = -999;
              break;
              }
      }
  usort($category_rows,'cat_sort');
  }

#
#-----[ FIND ]---------------------------------------------
# at End of File

?>

#
#-----[ BEFORE, ADD ]---------------------------------------
#

function cat_sort($x, $y) {
    if ( $x['cat_order'] == $y['cat_order'] )
        return 0;
    else if ( $x['cat_order'] < $y['cat_order'] )
        return -1;
    else
        return 1;
}


#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0286 seconds using 15 queries. (SQL 0.0022 Parse 0.0009 Other 0.0255)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo