by
KK » Sat May 19, 2018 3:09 pm
I'm sorting a lot of my pages into different categories ..
is there an easy way to have them collapsed by default when an admin logs on?
I ran into a similar situation recently. My solution was to do away with the 'Templates' group altogether and then create the multiple custom categories which showed up in a collapsed state to begin with and retained their collapsed/open status as the user clicks them open.
Here is a sample screenshot -
![sidebar.png](./download/file.php?id=2059&sid=02dc744eed22905e44c74697ac997714)
- sidebar.png (11.77 KiB) Viewed 3679 times
Any template not explicitly placed within one of those groups would appear in the root itself (as opposed to within the 'Templates' group as happens by default).
If the solution interests you, here is what needs to be done -
1. Turn on the sample admin theme by editing couch/config.php directive no. 26 and removing the leading double slashes -
- Code: Select all
//define( 'K_ADMIN_THEME', 'sample' );
2. As you know, with the sample theme activated, any template placed within the 'couch\theme\sample' folder would be used by Couch instead of the default system templates. In the attached zip, you'll find three such templates. Extract them and put them in 'couch\theme\sample'.
3. Finally edit the kfunctions.php file already present in 'couch\theme\sample' and append the following code to it -
- Code: Select all
// add new sidebar menu items
if( defined('K_ADMIN') ){
$FUNCS->add_event_listener( 'register_admin_menuitems', 'my_register_admin_menuitems' );
$FUNCS->add_event_listener( 'alter_admin_menuitems', 'my_alter_admin_menuitems' );
function my_register_admin_menuitems(){
global $FUNCS;
$FUNCS->register_admin_menuitem( array('name'=>'company', 'title'=>'Company', 'is_header'=>'1', 'weight'=>'1') );
$FUNCS->register_admin_menuitem( array('name'=>'calendar', 'title'=>'Calendar', 'is_header'=>'1', 'weight'=>'2') );
$FUNCS->register_admin_menuitem( array('name'=>'programs', 'title'=>'Programs', 'is_header'=>'1', 'weight'=>'3') );
$FUNCS->register_admin_menuitem( array('name'=>'support', 'title'=>'Support', 'is_header'=>'1', 'weight'=>'4') );
$FUNCS->register_admin_menuitem( array('name'=>'archive', 'title'=>'Archive', 'is_header'=>'1', 'weight'=>'5') );
}
function my_alter_admin_menuitems( &$items ){
global $FUNCS;
if( array_key_exists('_templates_', $items) ){
unset( $items['_templates_'] ); // removed this so now all templates by default go in '_root_'.
}
$items['_modules_']['weight']=100; // move administration group further down
}
}
And that should be it. You should find the menu items defined in the code above visible in the sidebar.
You may now edit/add/delete them to suit your use case.
Needless to say, any front end template can be placed within any of the categories defined above by using the 'parent' parameter of their <cms:template> block e.g.
- Code: Select all
<cms:template title='Items' parent='company' order='0' clonable='1'>
..
Please try it and let me know if this helps.