Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I'm sure I'm missing something horribly obvious in this.

I set up a csv export page as per http://www.couchcms.com/forum/viewtopic.php?f=3&t=8157&p=14962&hilit=csv#p14962.

Here's that code:

Code: Select all
<?php require_once ( '../couch/cms.php' ); ?>
<cms:content_type 'text/csv' />
First Name,Last Name,School,Grade,Age,Card Number,Hours or Books,Phone,Email,Library
<cms:pages masterpage='members/srp_database.php' folders=chosen_folders >
<cms:show first_name />,<cms:show last_name />,<cms:show school_attended />,<cms:show grade_level />,<cms:show age />,<cms:if pines_identifier><cms:show pines_identifier /><cms:else />0</cms:if>,<cms:show program_type_completed />,<cms:if contact_phone><cms:show contact_phone /><cms:else />None</cms:if>,<cms:if contact_email><cms:show contact_email /><cms:else />none</cms:if>,<cms:show k_folder_title />
</cms:pages>
<?php COUCH::invoke(); ?>


And then I'm calling that file (csv_export.php) over from this page:

Code: Select all
<?php require_once ( '../couch/cms.php' ); ?>
<cms:template title='SRP Readout Page' />
<cms:member_check_login />
<cms:if k_member_logged_in >
<!DOCTYPE HTML>
<html>
   <head>
      <cms:embed 'header.html' />
         
   </head>
   <body>
      <div class="container-fluid">
         <cms:embed 'menu.html' />
         
         <cms:form enctype="multipart/form-data" method="post" class="k_form" anchor='1'>
            <label>Choose your SRP Database Source(s)</label><p/>
            <cms:input type='checkbox' required='1' name='srp_source' opt_values=" Evans Library=evans_srp | Euchee Creek=euchee_srp | Harlem=harlem_srp | | Burke County=burke_srp | Midville=midville_srp | Sardis=sardis_srp | | Lincoln County=lincoln_srp | Warren County=warren_srp " />
            <p/>
            
            <button type='submit' class='btn btn-default'>Submit</button><p/>
         
               <cms:if k_success >
                  <cms:set chosen_folders=frm_srp_source 'global' />
                  
                  <a target="_blank" href="csv_export.php"><button class='btn btn-default'>Export to CSV</button></a>
                  <table id='datatable' class='table table-striped'>
                     <tr>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>School</th>
                        <th>Grade</th>
                        <th>Age</th>
                        <th>Card Number</th>
                        <th>Hours or Books</th>
                        <th>Phone</th>
                        <th>Email</th>
                        <th>Branch</th>
                     </tr>
                  <cms:pages masterpage='members/srp_database.php' folders="<cms:show frm_srp_source />" >
                     <tr>
                        <td><cms:show first_name /></td>
                        <td><cms:show last_name /></td>
                        <td><cms:show school_attended /></td>
                        <td><cms:show grade_level /></td>
                        <td><cms:show age /></td>
                        <td><cms:show pines_identifier /></td>
                        <td><cms:show program_type_completed /></td>
                        <td><cms:show contact_phone /></td>
                        <td><cms:show contact_email /></td>
                        <td><cms:show k_folder_title /></td>
                     </tr>
                  </cms:pages>
                  </table>
               <cms:else />
                  <h3 class='bg-warning'>You must select a branch or branches to pull SRP records from.</h3>
               </cms:if>
         </cms:form>      
      </div>
      
   </body>
</html>
<cms:else />

   <cms:redirect k_site_link />
   
</cms:if>
<?php COUCH::invoke(); ?>


When I click the "export" button on the page that displays the information, I get nothing at all. If I navigate directly to the page, then it downloads, but as a php file rather than .csv. Help?
Seems like a content-type issue (downloading as PHP).
Try removing the newline break after <cms:content_type 'text/csv' />
i.e. make it
Code: Select all
<?php require_once ( '../couch/cms.php' ); ?><cms:content_type 'text/csv' />First Name,Last Name,School,Grade,Age,C
...
Let us know if this helps.
I tried that, and it's still both failing to download form a link, when loaded directly downloading as a PHP file.
Here's what's being produced (as an example) by the csv_export.php

Code: Select all
First Name,Last Name,School,Grade,Age,Card Number,Hours or Books,Phone,Email


Zelda,Bloom,Hard Knocks,Pre-K,13,0,Books,None,none


<!-- Page generated by CouchCMS - Simple Open-Source Content Management -->


If all the code is on one line, it goes:

Code: Select all
First Name,Last Name,School,Grade,Age,Card Number,Hours or Books,Phone,EmailZelda,Bloom,Hard Knocks,Pre-K,13,0,Books,None,none
<!-- Page generated by CouchCMS - Simple Open-Source Content Management -->
Yay! I figured this out! But I have a new problem -

Is there a way for Couch to do more than 1000 loops of a page? I'm dealing with a database which can have potentially 4000 records, but it seems to cap the display at 1000.

Thanks,
Sam
5 posts Page 1 of 1