Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
16 posts Page 1 of 2
With a large number of templates to display in the admin sidebar, the following method could be very useful in making things more manageable -
Adding to the solution mentioned above -
I occasionally find myself using templates that only serve as auxiliaries (e.g. providing data to other templates) and need not be displayed in the sidebar.

Marking them as hidden only hides them from admins - the super-admin still gets to see them (albeit with a strikethrough line across the template entry). To completely hide them for everybody, I use the following code which is a modified form of the code used in the post linked above (please take a look at that to see what needs to be modified) -
Code: Select all
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

    // remove all hidden templates unless debug is on..
    if( !$_GET['debug'] ){

        $tpls = array( 'users.php', 'gallery.php', 'search.php' ); // set hidden templates

        foreach( $tpls as $tpl ){
            if( array_key_exists($tpl, $items) ){
                unset( $items[$tpl] );

The important line above is -
Code: Select all
 $tpls = array( 'users.php', 'gallery.php', 'search.php' ); // set hidden templates

where you can set the names of the templates to be removed from the sidebar.

This is typically done at the very end of development when the templates are no longer accessed directly.
Once hidden, if need arises to access those templates, one way of making them visible (the other being editing the kfunctions code above) would be to add '&debug=1' to the current url in admin panel address bar e.g. if the address bar currently shows -
Code: Select all

make it as follows to make the hidden templates visible -
Code: Select all

Hope this helps.
great feature, will try !! thank you !
I ran into a reverse situation where I needed to hide everything, except certain template(s). Following modification of original code helps -
Code: Select all
// hide everything from sidebar except allowed items
if( defined('K_ADMIN') ){
   $FUNCS->add_event_listener( 'alter_admin_menuitems', 'my_alter_admin_menuitems' );
   function my_alter_admin_menuitems( &$items ){
      // set visible templates and sections
      $tpls = array(
               ,   '_modules_'
               ,   'users'
               ,   'index.php'
      $items = array_intersect_key( $items, array_flip($tpls) );

In the code above one may add only expected items - I have only default Templates, Administration section and an index.php template with default Users template. Administration section and Users template can be also hidden - comment those out or remove from the list.
Hi, In fact, this is a real situation.
For example, the site has 3 administrators. Each administrator is responsible for specific departments:
- Admin 1 - he uploads products
- Admin 2 - he creates news
- Admin 3 - he deals with invoices

The problem is that all administrators have the same access to the server physical folders (through the file manager)

The question
How do we allow Administrator 1 to access only the Products physical folder?
How to allow Administrator 2 to access only the News physical folders
How to allow Administrator 3 to access only the Invoices physical folders

This is security considerations.
This will allow each administrator to be responsible for the files of his assigned department

If this is very complicated, we can dynamically hide physical folders with CSS ... Let's find a solution to this!

Thank you
Use htaccess password protection for each physical folder? Nevertheless, from within CouchCMS KCFinder's admins will *have* access to /uploads folder and any password-protected content in it - for example /uploads/image/protected-folder-1/

In other words, it is not yet possible to set different uploads folders per user. I wonder whether upcoming advanced user roles will have this tapped.
This is a very rough decision :shock:
I can solve the problem very easily, but the problem is that the file manager opens with the iframe.
I think the KK can propose a solution :)

Indeed many times my clients are interested in all this ...
This will be a very powerful push for new opportunities - such as a news site with many administrators who should not be able to commit malicious actions to a file manager!

Thanks in advance KK & Anton
Why is filemanager a concern? It's mostly images there.. Especially for a news site, images are of very little value :D
Let me introduce you to a real situation ...

I have several e-shops.
I can hire paid administrators to upload products, for example, a particular administrator may upload Group A products, another administrator may upload Group B products - this is a good practice i think.
But these are outsiders to whom I do not trust! They can do malicious actions and the site suffer, they also can accidentally make a mistake and delete a folder without knowing what they did!.

This is a normal situation, please agree with me :)
Of course you can do all sorts of stupid things in life, including hiring people you don't trust ;)

If there is a basic protection from your admins during upload, they can harm you in other ways easily.

If you must hire untrusted people - then consider giving them a job to put data into a csv or another special format, which will be read by your scripts. Do not give them admin rights! Write and use scripts instead that can upload products automatically and do many more things.
16 posts Page 1 of 2