Page MenuHomePhabricator

automatically open category tree to have selected categories visible
Open, MediumPublicFeature

Description

I'm using SelectCategory 0.8.

By default the category tree is collapsed (at least until you apply my patch from 27795 to fix $wgSelectCategoryMaxLevel ;-)

I'd like to have an additional config option ($wgSelectCategoryOpenSelected ?) that automatically opens all parts of the tree that contain a selected category.

For example, I an article belongs to the category "dog", the tree should be displayed like this:

  • animals
    • pets
      • dog <--- selected category
      • cat + wild

I'm not providing a patch this time ;-) but I'll give you some implementation hints:

The current code won't work :-( because you can't go upwards in the tree and mark an item as open, which is something you need to do to implement this.

A working variant is probably to have a nested array like (re-using my example categories from above)

$category_tree = array(

'animals' => array ( 0, 1, array(
    'dog'     => array ( 1, 0 ),
    'cat'     => array ( 0, 0 ),
),
'wild     => array ( 0, 0, array (
    # ...
)

)

The included arrays have the following structure: (example: 'animals')

  • selected?
  • open in tree by default?
  • array with sub-categories - if no sub-categories exist, you can
    • leave out this part (as in my example)
    • use an empty array()

You can also use named array keys, for example

'animals' => array ( selected => 0, open => 1, subcategories => array(...) ),

Version: unspecified
Severity: enhancement

Details

Reference
bz27796

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:29 PM
bzimport set Reference to bz27796.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM