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

I have this use case scenario:
1. DBF, used to save a persons fullname (First, Middle and Last Names, independently)
2. Same DBF has a repeatable region for subjects, multiple or no subject can be set.

What I want to Achieve:
Although a single form saves the persons name and subjects, I want to display the data in a tabular format with a new row for the same person with every subject.

Visually the output should be like below:
Code: Select all
--------------------------------------------------------------------------
Sr No    Name                                        Subject
--------------------------------------------------------------------------
1           John A. Doe                              Mathematics
2           John A. Doe                              Statistics
3           Jane B. Doe                              Economics
4           Jane B. Doe                              Business Funding
5           X Y Z                                         PMFBY
--------------------------------------------------------------------------


I tried something as:
Code: Select all
<cms:pages masterpage="claim/entry-form.php" paginate='1' limit='25'>
    <cms:capture into='line_items' scope='global'>
        <cms:show_repeatable 'subject_details'>
            <tr>
                <td>
                    <cms:show fname /> <cms:show mname /> <cms:show lname />
                </td>
                <td>
                    <cms:show subject_name />
                </td>
            </tr>
        </cms:show_repeatable>
        <cms:set subject_details_present='1' 'global' />
    </cms:capture>
</cms:pages>


And to display the output i have:
Code: Select all
<div class="table-responsive">
    <table class="table table-bordered table-hover table-condensed">
        <thead>
       <th class="text-center">
      Full Name
            </th>
            <th class="text-center">
      Subjects Opted
            </th>
        </thead>
        <tbody>
            <cms:show line_items />
        </tbody>
    </table>
</div>


But i am unable to list all the names at once. with a new row for each subject opted.

Please help!

Regards,
Aashish
Image
where innovation meets technology
Well I found it.
I just moved the <cms:capture> outside the <cms:pages>.

Code: Select all
<cms:capture into='line_items' scope='global'>
    <cms:pages masterpage="claim/entry-form.php" paginate='1' limit='25'>
        <cms:show_repeatable 'subject_details'>
            ...
        </cms:show_repeatable>
    </cms:pages>
<cms:capture>


And it is generating the output as:
Code: Select all
--------------------------------------------------------------------------
Sr No    Name                                        Subject
--------------------------------------------------------------------------
1           John A. Doe                              Mathematics
2           John A. Doe                              Statistics
3           Jane B. Doe                              Economics
4           Jane B. Doe                              Business Funding
5           X Y Z                                         PMFBY
--------------------------------------------------------------------------


Regards,
Aashish
Image
where innovation meets technology
I guess I was too quick to celebrate.

I have been able to generate the table.
Now I am trying to export the csv in the same format as the table.

How do I generate repeated rows for same person and different subject?

Any help please!

Regards,
Aashish
Image
where innovation meets technology
@KK sir and other Couch Developers

Any help would be appreciated!

I have about 1000's clonable pages. Each clonable page has a repeatable region. I want to generate a CSV as shown in tabular format in above posts.
But the issue is that the CSV generates the output with the repeatable regions only upto the first 1000 pages, i.e. if there are an average of 3 repeatable fields filled for each clonable page then the outpot only shows 3000 csv entries. While there exist more than 1000 cloned pages.

How can I generate the total cloned pages output and not only of 1000 pages? I tried to generate the output by setting the cms:pages limit to a larger number as limit="100000". But still only the output of the first 1000 pages is generated.

Regards,
GenXCoders (Priya)
Image
where innovation meets technology
The 'limit' param of <cms:pages>, if not explicitly set, defaults to a value of '1000'.
So, setting the limit to a higher number, as you said you did, is the correct solution.

As to why only 1000 pages are still being fetched, try adding a return_sql='1' to the <cms:pages> tag temporarily.
Take a look at the SQL being generated to see if the LIMIT in it matches that you set on the tag.
EDIT#1: @KK Sir, i set max_execution_time to a high value and the output csv gave me all values as per requirement. But it is as high as 800. What to do? I suppose this script execution timeout is the reason of my issue. Please enlighten me.

KK wrote: As to why only 1000 pages are still being fetched, try adding a return_sql='1' to the <cms:pages> tag temporarily.
Take a look at the SQL being generated to see if the LIMIT in it matches that you set on the tag.


I did this sir. And it returned the following:
SELECT p.id, p.template_id FROM couch_pages p inner join couch_data_text t0 on t0.page_id = p.id WHERE p.template_id='8' AND p.publish_date < '2021-01-23 02:55:42' AND NOT p.publish_date = '0000-00-00 00:00:00' AND p.parent_id=0 AND ( t0.field_id=34 ) AND ( t0.search_value LIKE '%%' ) ORDER BY p.publish_date desc LIMIT 0, 20000

for the statement:
Code: Select all
<cms:pages masterpage="claim/entry-form.php" limit="20000" custom_field="entry_date='<cms:show filter />'" return_sql='1' />

where <cms:show filter /> displays the date in Y-m-d format already set using cms:set statement.

There are two outputs that I am needed to generate, viz:
1. Tabular Format (Generates all values perfectly with above cms:pages code)
2. CSV Format (Does not generate all values in CSV with above cms:pages code)

For example, I have the following entries made in last three days:
Code: Select all
---------------------------------------------------------------------------------------------------------------------------------------------
Sr No   Date                                            Pages                           Line Items (Generated by Repeatable Regions)
---------------------------------------------------------------------------------------------------------------------------------------------
1.         2021-01-20                                 303                               796
2.         2021-01-21                                 1452                             3398
3.         2021-01-22                                 697                               1771
---------------------------------------------------------------------------------------------------------------------------------------------


Now when I generate the Tabular Format all data appears correct table rows (Line Items) for #1, #2, #3 of the table above.
But, when I generate the CSV format, I get the following counts with the same cms:pages I mentioned above:

Code: Select all
---------------------------------------------------------------------------------------------------------------------------------------------
Sr No   Date                                            Pages                           Line Items (Generated by Repeatable Regions)
---------------------------------------------------------------------------------------------------------------------------------------------
1.         2021-01-20                                 303                               796
2.         2021-01-21                                 640                               1443 (This CSV count changes every time)
3.         2021-01-22                                 574                               1476 (This CSV count changes every time)
---------------------------------------------------------------------------------------------------------------------------------------------


Unable to understand why the same cms:pages is not working similarly for tabular and CSV formats.

Regards,
GenXCoders (Priya)

REQUEST: KK Sir could you also provide an example of 'staggered' method for the CSV Exporter module as explained in CSV Importer module. Because I could not understand using use_cache='1' in the exporter.
Image
where innovation meets technology
6 posts Page 1 of 1