Forum for discussing general topics related to Couch.
13 posts Page 2 of 2
Think that's where I have gone wrong, I did not copy his code to it as it looked like it was customised for the user above his post on viewtopic.php?f=4&t=11511&p=30740#p30740

I got confused by it to be honest, below is the kfunctions.php file I have in the admin/theme/sample folder

Code: Select all
<?php
    if ( !defined('K_COUCH_DIR') ) die(); // cannot be loaded directly

    function k_override_renderables(){
        global $FUNCS;

        // add more candidate template names for renderables implemented as templates
        $FUNCS->add_event_listener( K_THEME_NAME.'_alter_render_vars_content_list_inner', 'MyTheme::_alter_render_vars' );
        $FUNCS->add_event_listener( K_THEME_NAME.'_alter_render_vars_content_form', 'MyTheme::_alter_render_vars' );
    }


    // class containing the theme functions
    class MyTheme{

        static function _alter_render_vars( &$candidate_templates, $name, $args ){
            global $FUNCS, $CTX;

            // for every candidate template for the renderable, add a template that has the current masterpage suffixed
            $cur_route = $FUNCS->current_route;
            $cur_masterpage = $FUNCS->get_clean_url( $cur_route->masterpage ); // e.g., this will turn 'en/blog.php' into 'en-blog-php'.

            $tmp_array = array();
            foreach( $candidate_templates as $tpl ){
                $tmp_array[] = $tpl;

                if( $cur_route->module=='folders' ){
                    $tmp_array[] = $tpl . '__folder';
                    $tmp_array[] = $tpl . '__folder_' . $cur_masterpage;
                }
                else{
                    $tmp_array[] = $tpl . '_' . $cur_masterpage;
                }
            }

            $candidate_templates = $tmp_array;
        }

    }// end class
   
   // remove certain templates for everyone except superadmin
    function my_alter_admin_menuitems( &$items ){
        global $AUTH;

        // set hidden templates -
        $tpls = array(
                    'template-to-hide.php'
                ,   'another-template-to-hide.php'
                ,   'index.php'
                ,   'users.php' // extended users template
                ,   'users'     // system 'USERS' section
        );

        // a freeway for superadmin
        if( $AUTH->user->access_level == 10 ) return;

        if( array_key_exists('_modules_', $items) ){
            unset( $items['_modules_'] ); // hide empty Administration section
        }
        foreach( $tpls as $tpl ){
            if( array_key_exists($tpl, $items) ){
                unset( $items[$tpl] );
            }
        }
    }

Just a update on this, I found this link: viewtopic.php?f=2&t=11464#

It does work as it has removed the Users link from under the administration heading for anyone except superadmin but the administration heading still shows, is there any way to remove that as well someone, The coding I got in couch/addons/kfunctions.php is below

Code: Select all
/*
    Remove 'Users' section for everyone except super-admins
*/
$FUNCS->add_event_listener( 'alter_admin_menuitems', 'my_func_alter_admin_menuitems' );
function my_func_alter_admin_menuitems( &$menu_items ){
    global $AUTH;

    if( $AUTH->user->access_level < '10' ){ // if not a super-admin
        if( array_key_exists('users', $menu_items) ){
            unset( $menu_items['users'] )  ;
        }
    }
}
UPDATE: I have done it using this link viewtopic.php?f=8&t=10715&start=10#p28371 and download the sidebar.zip and uploaded it to the sample theme folder and uncommented the line in the config file to use the sample theme

It works perfect now

Thank you for helping and replying etc.
13 posts Page 2 of 2