Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hello all,

I'm adding couchcms to HTML website to customize it and


Issue 1 :
we are including a form with file upload which needs to be in admin panel for CRUD functions. I've followed the tutorial and implemented a snippet to show the admin page however it does not there is no css on this snippet so I had to add inline code.
The photos are uploaded to the server how do I show them in the admin panel? I'm sharing the snippet code. The delete functionality is not working either.

Code: Select all
<cms:php>
    // Set info about selected folder
    global $DB, $CTX, $FUNCS;
   
    $fid = ( isset($_GET['fid']) && $FUNCS->is_non_zero_natural($_GET['fid']) ) ? (int)$_GET['fid'] : null;
    if( $fid ){
        $rs = $DB->select( K_TBL_FOLDERS, array('name'), "id='" . $DB->sanitize( $fid ). "'" );
        if( count($rs) ){
            $fname = $rs[0]['name'];
        }
    }
   
    $CTX->set( 'my_selected_fid', $fid, 'global' );
    $CTX->set( 'my_selected_fname', $fname, 'global' );
</cms:php>

<cms:capture into='my_folders' scope='global'>
    <cms:if k_folder_totalchildren >
        <div class="bulk-actions">
           
            <cms:dropdownfolders masterpage='page3.php' prompt='View all folders' hierarchical='1' selected_id=my_selected_fid />
           
            <a class="button" id="btn_folder_submit"
                href="<cms:admin_link />"
                onclick="this.style.cursor='wait'; return false;" >
                <span>Filter</span>
            </a>
           
        </div>
    </cms:if>
</cms:capture>

   
<cms:capture into='my_list' scope='global'>
<style>
        table {
          border-collapse: collapse;
          width: 100%;
        }

        td, th {
          border: 1px solid #dddddd;
          text-align: left;
          padding: 8px;
        }

        tr:nth-child(even) {
          background-color: #dddddd;
}
</style>

    <table class="listing clear" cellspacing="10" cellpadding="10" >
   
        <thead>
            <tr>
                <th class="checkbox">
                    <input type="checkbox" name="check-all" onclick="$$('.page-selector').set('checked', this.checked);">
                </th>
               
                <!-- EDIT -->
                <th>Name</th>
                <th>Mobile</th>
                <th>Email</th>
                <th>Photo</th>
                <th>Date</th>
                <th>Actions</th>
                <!-- END EDIT -->
               
            </tr>
        </thead>
       
        <tbody>   
           
            <cms:pages masterpage=k_template_name folder=my_selected_fname paginate='1' limit='12' show_unpublished='1' >
                <cms:if k_paginated_bottom >
                    <cms:if k_paginator_required >
                        <cms:capture into='my_paginator' scope='global'>
                            <cms:php>
                                global $CTX, $FUNCS;
                               
                                // Paginator assumes front-end template link as base. Make it point to the back-end.
                                $pagination_link = $CTX->get( 'k_page_being_paginated' );
                                $pagination_link = str_replace( $CTX->get('k_template_link'), $CTX->get('k_admin_link'), $pagination_link );
                                $CTX->set( 'k_page_being_paginated', $pagination_link );
                            </cms:php>
                            <cms:paginator adjacents='2' />
                            <div class="record-count">Showing <cms:show k_record_from />-<cms:show k_record_to /> / <cms:show k_total_records /></div>
                        </cms:capture>   
                    </cms:if>
                    <cms:set row_class='last_row' />
                </cms:if>
               
                <!-- EDIT -->
                <tr>
                    <td class="checkbox <cms:show row_class />">
                        <input type="checkbox" value="<cms:show k_page_id />" class="page-selector" name="page-id[]">
                    </td>

                    <td class="name <cms:show row_class />">
                        <a href="<cms:admin_link />" >
                            <cms:show name />
                        </a>
                    </td>

                    <td class="name <cms:show row_class />"><cms:show mobile /></td>
                   
                    <td class="name <cms:show row_class />"><cms:show mail /></td>

                    <td class="name <cms:show row_class />"><cms:show photo /> </td>
                   
                    <td class="date <cms:show row_class />"><cms:if k_page_date=='0000-00-00 00:00:00' >Unpublished<cms:else /><cms:date k_page_date format='M jS Y' /></cms:if></td>
                   
                    <td class="actions <cms:show row_class />">
                        <!-- edit -->
                        <a href="<cms:admin_link />">
                            <img src="<cms:show k_admin_link />theme/images/page_white_edit.gif" title="Edit">
                        </a>
                       
                        <!-- delete -->
                        <a href="<cms:admin_delete_link />"
                            onclick="if( confirm('Are you sure you want to delete page: <cms:show k_page_name />?') ) { return true; } return false;">
                            <img src="<cms:show k_admin_link />theme/images/page_white_delete.gif" title="Delete">
                        </a>
                       
                        <!-- view -->
                        <a href="<cms:show k_page_link />" target="_blank" title="View">
                            <img src="<cms:show k_admin_link />theme/images/magnifier.gif">
                        </a>
                    </td>
                </tr>
                 
                <cms:no_results>
                    <tr><td colspan="6" class="last_row" style="text-align:center">No pages found</td></tr>
                </cms:no_results>
               
                <!-- END EDIT -->
               
            </cms:pages>
        </tbody>
    </table>
</cms:capture>


<form name="frm_list_pages" id="frm_list_pages" action="" method="post">

    <div class="wrap-paginator">
        <cms:show my_folders />
        <cms:show my_paginator />
    </div>

    <div class="group-wrapper listing">
        <cms:show my_list />
    </div>

    <div class="wrap-paginator">
        <div class="bulk-actions">
            <a class="button" id="btn_bulk_submit" href="#">
                <span>Delete Selected</span>
            </a>
        </div>
       
        <cms:show my_paginator />
    </div>
   
    <input type="hidden" id="nonce" name="nonce" value="<cms:php>global $FUNCS; echo $FUNCS->create_nonce( 'bulk_action_page' );</cms:php>">
    <input type="hidden" id="bulk-action" name="bulk-action" value="delete">
   
</form>


<script type="text/javascript">
    <![CDATA[
    window.addEvent('domready', function(){
        if( $('btn_folder_submit') ){
            $('btn_folder_submit').addEvent('click', function(e){
                var link = this.href
                var fid = $('f_k_folders').value;
                if( fid != -1 ){
                    link += '&fid=' + fid;
                }
                document.location.href = link;
            });
        }
    });
   
    function k_hook_bulk_submit(){
        if( $('btn_bulk_submit') ){
            $('btn_bulk_submit').addEvent('click', function(e){
                var col = $$('.page-selector');
                for( var x=0; x<col.length; x++ ){
                    if( col[x].checked ){
                        if( confirm('<cms:php> global $FUNCS; echo $FUNCS->t('confirm_delete_selected_pages'); </cms:php>') ){
                            $$('body').setStyle('cursor', 'wait');
                            $('frm_list_pages').submit();
                        }
                        return false;
                    }
                }
                return false;
                });
        }
    }
    window.addEvent( 'domready', k_hook_bulk_submit );
    ]]>
</script>



Issue 2:
There is another textarea on the page3.php along with the form that needs to be editable however, every time I add an editable textarea to the page it showed in the admin panel with the entry form edit page. How do add this editable textarea separately than Entry form.
    page1.php (Customizable textarea)
    page3.php (Customizable textarea)
    Entry Form (Form CRUD)
Hi,

I think you are trying to implement a 'custom admin screen' to show the uploaded images on the listing page.
The procedure to do that has changed (become easier and more powerful) with Couch v2.0.

Please take a look at viewtopic.php?f=5&t=10241 that details all the customization available to you. Chances are you'd be able to do the customization you need by simply using <cms:config_list_view>.

Hope this helps.
Hi,

Thanks for the reply and it resolved my main issue. However, the Delete functionality is still not working on the website to delete entries of the databound form. Am I missing a Js file or script?
KK wrote: Hi,

I think you are trying to implement a 'custom admin screen' to show the uploaded images on the listing page.
The procedure to do that has changed (become easier and more powerful) with Couch v2.0.

Please take a look at viewtopic.php?f=5&t=10241 that details all the customization available to you. Chances are you'd be able to do the customization you need by simply using <cms:config_list_view>.

Hope this helps.


Hi,
@KK
Thanks for the reply and it resolved my main issue. However, I'm still not able to resolve Issue 2 mentioned initially in the question as below -

Issue 2:
There is another textarea on the page3.php along with the form that needs to be editable however, every time I add an editable textarea to the page it showed in the admin panel with the entry form edit page. How do add this editable textarea separately than Entry form.
page1.php (Customizable textarea)
page3.php (Customizable textarea)
Entry Form (Form CRUD)
4 posts Page 1 of 1