Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
8 posts Page 1 of 1
If it possible to add one more button, "save and back"?

One user click on it, it will display save message and redirect back to parent template.

Example, I have a photo gallery folder, which consists over hundred products and user bulk upload it. it is really not that convenience to click the folder every time. User probably just changing the name, once they click on "save and back", they just redirect back to related folder content then they can just easily click on second products and rename it without choose the folder everytime.

As I noticed, most of the current CMS system, they do consists this few buttons to make the system user friendly, "save", "save and back", "view".

Please take note, the redirect is not just go back to parent/sub folder/page, it should go back to related pages. For example, I am editing a product from "bedroom" folder, page 2, after I edit it, and click "save and back" button, it will go back to the bedroom folder and page 2.

Or perhaps we can just make it easy, to just let the button redirect to previous page. But for this case, the system have to detect if the template has sub-folders or clonable pages, if it does, it will show three buttons, "save", "save and back" and "view". If it doesn't, it will simply just show "save" and "view" buttons, so it won't redirect to non-related previous page.

This is really quite a important feature to me, I create quite a lot of projects which required to upload more than 100 products/categories. I've accepted complaining about limited search function, "save without redirect" and "save without alert" problem. Hopefully it can be fixed within this version.


According to KK's suggestion, I can click on the header title to redirect back, but I just need it to be more user friendly, I want to keep the whole process with one click, sorry for my client just too dumb to remember that click header title has the same function as click "back" function. Or maybe a "back" button beside "save" button should work just fine. Any suggestion?
I agree, this is a very good suggestion and actually is much more user friendly.

For example, with Apple devices the whole world already knows about swipe gesture, which is not obvious, but thanks to the marketing and huge user base we are aware of it. For CouchCMS, which is a very small niche product, everything should be very friendly without guessing, all holes must be covered with appropriate buttons and labels :lol: Because there is no documentation about user interface and it's not obvious for inexxperienced people who see a laptop, browser and an admin panel for the first time. :?
@trendoman, glad to see that you're on my side on this point.

I studied quite a few CMS before I use Couchcms. I believe what I asked is a really common and basic function. I choose Couchcms because it's really easy to integrate with customize website and the good customer services. The others like Magento, they are a very powerful CMS, but they just too complex and heavy for small project and my client is feeling headache on using the this CMS, COMPLEX.

But it's a open discussion, I am not forcing the crew to come out the solution for me. I just really appreciate if anyone can actually provide some good advises. Thanks.
Direct pagination is here viewtopic.php?f=8&t=10169 This will temporarily alleviate the issue.
@nsy, thank you for your suggestion.
Please grant me a few days and I'll try to come up with a proper solution.

The Wall has fallen and we gonna receive something requested? That's cool :D I'm happy for you @nsy.
KK wrote: @nsy, thank you for your suggestion.
Please grant me a few days and I'll try to come up with a proper solution.


May I know if you already have a solution on this case?
Sorry for the delay @nsy.
Here is one possible solution -

Please copy the code below and paste it into your 'couch/addons/kfunctions.php' file (if this file is not found, rename the 'kfunctions.example.php' to make it 'kfunctions.php').
Code: Select all
if( defined('K_ADMIN') ){ // if admin-panel being displayed ..

    // 1. Add a 'Save and back' button to form view
    $my_target_action = 'page'; // available targets on the form are - toolbar, filter, page and extended

    $FUNCS->add_event_listener( 'alter_pages_form_'.$my_target_action.'_actions', 'my_add_button' );
    function my_add_button( &$arr_actions, &$obj ){
        global $FUNCS, $PAGE;

        $route = $FUNCS->current_route;
        if( is_object($route) && $route->module=='pages' ){

            if( $PAGE->tpl_is_clonable ){ // if template is clonable, add the new button to form

                $arr_actions['btn_save_and_back'] =
                        'title'=>'Save and go back',
                            "var form = $('#".$obj->form_name."');",
                            "return false;",

    // 2. When the button above submits the form, take custom action (go back to list-view in this case)
    $FUNCS->add_event_listener( 'pages_form_custom_action', 'my_add_button_action' );
    function my_add_button_action( $custom_action, &$redirect_dest, &$pg, $_mode ){
        global $FUNCS, $PAGE;

        $route = $FUNCS->current_route;
        if( is_object($route) && $route->module=='pages' ){

            if( $custom_action === 'save_and_back' ){
                // set the new redirect destination (the list view with all querystring parameters) ..

                if( $PAGE->tpl_is_clonable ){
                    $link = $FUNCS->generate_route( $PAGE->tpl_name, 'list_view' );
                    $link = $FUNCS->get_qs_link( $link );

                    $redirect_dest = $link;

And now you should see an additional button while editing any page of a *clonable* template.
Saving the page using this button should take you back to that template's list-view preserving all folder info etc. that you had before coming to the edit page.

Hope it helps. Do let me know.
8 posts Page 1 of 1

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests