Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
4 posts Page 1 of 1
A solution to 1-click publish/unpublish (viewtopic.php?f=4&p=31327#p31322)

2018-07-27-001.png (10.43 KiB) Viewed 646 times

Code: Select all

<cms:config_list_view >

      <cms:if "<cms:get_flash 'publish_status_success' />" >
            $(function() {
               toastr.success("Your changes have been saved", "Success", { // TODO: localize
                  "positionClass": "toast-bottom-right",
                  "showDuration": "250",
                  "hideDuration": "250",
                  "timeOut": "2500",
                  "extendedTimeOut": "500",
                  "icon": '<cms:show_icon 'check' />'

      <cms:if "<cms:is_ajax />">
         <cms:set status = "<cms:gpc 'status' />" />
         <cms:set pageid = "<cms:gpc 'id' />" />
         <cms:if status eq '1' >
            <cms:set new_publish_date = "<cms:date format='Y-m-d H:i:s' />" />
         <cms:else />   
            <cms:set new_publish_date = "0000-00-00 00:00:00" />
            _page_id = pageid
            <cms:if k_success>
               <cms:set result_msg = 'Success!' scope='global'/>
               <cms:set_flash name='publish_status_success' value='1' />
            <cms:if k_error>
               <cms:set result_msg = 'Error!' scope='global'/>
         <cms:abort msg=result_msg />

      function k_delete_single( id, name ){
         var msg;
         if( name ){
            msg = 'Are you sure you want to delete page: '+name+'?';
            msg = 'Are you sure you want to delete page';
         if( confirm(msg) ){
            $('body').css('cursor', 'wait');

            var form = $('#k_admin_frm_list');
            var checkboxes = form.find( '.checkbox-item' ).not( ':disabled' );
            checkboxes.prop( 'checked', false );

            var col = $('#page-selector-'+id);
            col.prop( 'checked', true );

         return false;
      function change_publish_status( id, status, name ){
         var msg = '';
         if( status === '1'){
            msg = 'Are you sure you want to publish page: '+name+'?';
            msg = 'Are you sure you want to un-publish page: '+name+'?';
         if( confirm(msg) ){

            $('body').css('cursor', 'wait');
               method: "POST",
               url: "<cms:show k_qs_link />",
               data: { id: id, status: status },
                  success: function(data) {



   <cms:if k_template_is_clonable = '1' >   
      <cms:field 'k_selector_checkbox' />
      <cms:field 'k_page_title' />
      <cms:field 'k_comments_count' />
      <cms:field 'k_page_foldertitle' />
      <cms:field 'k_page_date' />
      <cms:field 'k_actions' >
            <a class="icon tt" href="<cms:show k_update_link />" title="" data-original-title="Edit">
               <cms:show_icon name='pencil' />
            <cms:if k_page_date = '0000-00-00 00:00:00' >
               <a class="icon tt" href="#" title="" onclick="change_publish_status( '<cms:show k_page_id />', '1', '<cms:show k_page_title />' ); return false;" data-original-title="Publish" style="fill:red">
                  <cms:show_icon name='power-standby' />
            <cms:else />
               <a class="icon tt" href="#" title="" onclick="change_publish_status( '<cms:show k_page_id />', '0', '<cms:show k_page_title />' ); return false;" data-original-title="Unpublish">
                  <cms:show_icon name='power-standby' />

            <a class="icon tt delete-list" href="#" onclick="k_delete_single( '<cms:show k_page_id />', '<cms:show k_page_title />' ); return false;" title="" data-original-title="Delete">
               <cms:show_icon name='trash' />
            <a class="icon tt" href="<cms:show k_view_link />" target="_blank" title="" data-original-title="View">
               <cms:show_icon name='magnifying-glass' />
            <a class="btn btn-actions" role="button" tabindex="0">
               <cms:show_icon name='ellipses' />


Solution effectively recreates action buttons and adds an extra button there.
A click on new button sends an ajax request to the backend. A css trick marks the svg icon with color if page is unpublished. Various types of confirmations employed, so you can disable those you don't want.
active topics, google
Free support is never free.. Donate!

Can this be implemented from the front end?

For example, If there is a clonable template creating employees and the employees need to be activated or deactivated. So can it be achieved by the front end as well? If so, how?

I could see the backend function, but can that entire function be replicated on frontend in extended user module?

Nevertheless, great work there!

where innovation meets technology

This has been working great, saving a lot of time!

Could you possibly extend the ability to toggle the pages publish status via selecting checkboxes and the batch drop down? :)
I can see a way to do it via dropdown and unpublish-publish in bulk.
A jQuery script could add another option to dropdown dynamically. Backend code should take care of submitted string of page ids. Code above only deals with a single id.
If you don't want to mess with js-ajax-coding, PM me for a quote.
active topics, google
Free support is never free.. Donate!
4 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