Forum for discussing general topics related to Couch.
8 posts Page 1 of 1
Hello...

Let's say i have this repeatable region:
Code: Select all
<cms:repeatable name='addresses' >
   <cms:editable type='text' label='Name' name='name' />
   <cms:editable type='text' label='City' name='city' />
   <cms:editable type='text' label='Zip Code' name='zip' />
</cms:repeatable>

and in the frontend, i want to display the values as tabular data:
Code: Select all
<table>
   <thead>
      <tr>
         <td>Name</td>
         <td>City</td>
         <td>Zip Code</td>
      </tr>
   </thead>
   <tbody>
      <cms:show_repeatable>
      <tr>
         <td><cms:show name /></td>
         <td><cms:show city /></td>
         <td><cms:show zip /></td>
      </tr>
      </cms:show_repeatable>
   </tbody>
</table>

Because i will be have hundreds of rows, i don't want to display them in a single page, that's why i need a pagination.
I can't use cms:paginator, can i ?
I know there are 'k_count' and 'k_total_records' variables so i could search on google for a snippet to show pagination in the frontend,
but what about in the backend? how if i have to click "Add a Row" a hundred times ?
Hello littlekoala,

If you have hundreds of rows, I think you should consider using normal cloned pages (one page per row) instead of repeatable-regions. Repeatable regions are not meant for huge amount of data and hence don't support pagination.
KK wrote: Hello littlekoala,

If you have hundreds of rows, I think you should consider using normal cloned pages (one page per row) instead of repeatable-regions. Repeatable regions are not meant for huge amount of data and hence don't support pagination.


Hello KK,

I am afraid you are right, looking on how couch store the repeatable region values in the database, it is a bad idea to use the repeatable region if i have hundreds of rows.

So if i go with the normal cloned pages, the code should be something like this (please correct me if i am wrong):

Code: Select all
<!--- address.php -->
<cms:template title='Address List' clonable='1'>
   <cms:editable name='city' type='text' label='City' />
   <cms:editable name='zip' type='text' label='Zip Code' />
</cms:template>

<cms:if k_is_page>

   <!---- in here, actually i don't need the page, because it will only have
   name (title), city and zip as a content, can i hide the "single page" and the page url that generated ?
   and when we "Add new page" can we change the "Title" label and hide "system generated name" field ?
   what is you opinion ?
   -->

<cms:else />

   <cms:embed 'address_list.html' />  <!--- Let's say i have a snippets named address_list.html -->

</cms:if>

Please note the comment in the code above.

and in the address_list.html :
Code: Select all
<cms:if k_paginated_top>
   <table border="1">
      <thead>
         <tr>
            <td>Name</td>
            <td>City</td>
            <td>Zip Code</td>
         </tr>
      </thead>
      <tbody>
</cms:if>

         <tr>
            <td><cms:show k_page_title /></td>
            <td><cms:show city /></td>
            <td><cms:show zip /></td>
         </tr>
      
<cms:if k_paginated_bottom>      
      </tbody>
      <tfoot>
         <tr>
            <td colspan='3'><cms:paginator /></td>
         </tr>
      </tfoot>
   </table>
</cms:if>

</cms:pages>
in here, actually i don't need the page, because it will only have
name (title), city and zip as a content, can i hide the "single page" and the page url that generated ?
If you don't need a single page, simply don't implement the <cms:if k_is_page> block. On the front-end since there would be no links to the page-view (from other parts of the site) the single pages, for all practical purposes, won't exist.

On the backend, there is no straightforward way of hiding the 'magnifying glass' icon that invokes the page-view but perhaps you can try the technique I'm going to suggest next for your other question.
and when we "Add new page" can we change the "Title" label and hide "system generated name" field ?
what is you opinion ?
I think you'll find the following post useful -
viewtopic.php?p=14563#p14563

Hope it helps.
I guess i am on the right track. Thanks KK, you are awesome !

KK wrote: ... I think you'll find the following post useful -
viewtopic.php?p=14563#p14563

Hope it helps.

You are right, the above post is useful, i can change the "Title" label and hide system generated "Name" field with that trick.

Another question, in the backend, there is a list of "pages" displayed in table (the table with column: title, folder, date, actions), is there any trick to change how the table displayed ? for example i want the "folder" column hidden.
cms:editable type="message" only injected in a "single page" right? how to inject some code to the list of "pages" ?

Thanks.
There is not much tweaking we can do there, I'm afraid.
However, you can replace the *entire* listing with your own design - please see http://www.couchcms.com/docs/concepts/d ... forms.html. The 'Custom admin-screens' section details how to do that. The downloadable source code on the page provides sample implementation you can use as a starting point.

Hope it helps.
KK wrote: There is not much tweaking we can do there, I'm afraid.
However, you can replace the *entire* listing with your own design - please see http://www.couchcms.com/docs/concepts/d ... forms.html. The 'Custom admin-screens' section details how to do that. The downloadable source code on the page provides sample implementation you can use as a starting point.

Hope it helps.

Are you kidding me KK.... it Helps a lot !!!! :D

I will dig into this "Databound form" further next week, as i see this will be excellent for my next project.

God bless you KK.
Thank you :)
I'm glad I could help.
8 posts Page 1 of 1
cron