Forum for discussing general topics related to Couch.
14 posts Page 1 of 2
I have a template 'index.php' where there are small blocks of text. Users need to be able to add/delete/edit these blocks of text. Currently these blocks of text are rows in a repeatable region in this template. I have designed a addText form to let people add more text(ie. add more rows to the repeatable group and put text in them), But I have been unable to bind it to a repeatable region. How can I let users add repeatable rows with their own text in each? (through the front end)

Moreover, I am planning to make this index.php clonable so that each registered user will have a cloned page from this template, accessible(and editable) only to him/her. Is this possible using the members module?

Also how can I get the date(and time) at which a particular repeatable region was added, and show it along with the text?
Hello and welcome mercurial :)

I think using repeatable regions for what you are trying to do wouldn't be a good idea.
We'd be better off using a separate template for the 'rows' (each row would be a cloned page) and relating it with the main template (index.php, I gather).

Moreover, I am planning to make this index.php clonable so that each registered user will have a cloned page from this template, accessible(and editable) only to him/her. Is this possible using the members module?
Should be straightforward. You just need to relate a cloned page with the user (http://www.couchcms.com/docs/concepts/r ... ships.html) in a one-to-one relation.

Also how can I get the date(and time) at which a particular repeatable region was added, and show it along with the text?
Assuming we use a cloned page for a row, the date of creation would be available as a regular variable.

In closing, I am in the process of creating a tutorial where we create a (somewhat) complex site using Couch's advanced features like relations, extended-users, DataBound Forms etc.
If you could wait for just a few days, i think you'll find it useful in creating the kind of functionality you described.

Thanks.
KK wrote: Hello and welcome mercurial :)
In closing, I am in the process of creating a tutorial where we create a (somewhat) complex site using Couch's advanced features like relations, extended-users, DataBound Forms etc.


AWESOME!!! :lol:
I am in the process of creating a tutorial where we create a (somewhat) complex site using Couch's advanced features like relations, extended-users, DataBound Forms etc.

This sounds invaluable and will help bring to life the new features of Couch. Thank you!
Thanks, I set up the site to use cloned pages instead of repeatable regions, and it works. :)
KK wrote: Should be straightforward. You just need to relate a cloned page with the user (http://www.couchcms.com/docs/concepts/r ... ships.html) in a one-to-one relation.
So, now when a member adds text through the databound form, it gets stored as a new page in a template which stores the text (this is the template I used to replace the repeatable region). I need this page to be related to the member automatically, without needing any intervention from the member. (so that I can group together each members posts and show it on index.php) How do I do this?

Also, if I have the k_page_name of a cloned page of something.php, how can I query the respective k_page_title?

And, how to prevent the creation of default page for each clonable template?

-Thanks in advance.
I need this page to be related to the member automatically,

Two solutions -
a. Use 'extended-users' (viewtopic.php?f=5&t=8581).
This way each user account will also have an equivalent cloned-page. Create a relationship between the extended-user template and the text template.

b. Create an editable region (type:text, search_type:integer), say named 'owner_id', and then store into this the ID of the logged-in user (while saving the text through DataBound Form).
To query back the pages belonging to a particular user, use 'custom_field' parameter of cms:pages tag.

Also, if I have the k_page_name of a cloned page of something.php, how can I query the respective k_page_title?
Use cms:pages to fetch the page with the k_page_name. All the data (including k_page_title) will become available e.g.
Code: Select all
<cms:pages masterpage='something.php' page_name='name_of_a_page' limit='1'>
    <cms:show k_page_title />
</cms:pages>


And, how to prevent the creation of default page for each clonable template?
This cannot be prevented. If you delete a default page, Couch will create one again.
Best way to deal with this is to unpublish the default page (this way it will not be listed on the front-end) and name it something like 'PLEASE DO NOT DELETE'.

Hope this helps.
Thank you very much.
But just one doubt
KK wrote: b. Create an editable region (type:text, search_type:integer), say named 'owner_id', and then store into this the ID of the logged-in user (while saving the text through DataBound Form).

I couldnt find the code to include values while submitting through databound forms. Can you please show me the code required to pass the member id along with the databound form on submission. Sorry for being noob.
Not a problem :)

The cms:db_persist_form tag can be explicitly provided values to save e.g. as follows -
Code: Select all
<cms:db_persist_form 
    k_page_name='my-page-name'
    k_page_title='My Page Name'
    owner_id=k_user_id
/> 
In the sample code above we are setting two system fields and one custom field directly. The 'owner_id=k_user_id' part is what you are looking for (assuming the user accessing the form is logged-in).

Hope this helps.
KK wrote: Not a problem :)

The cms:db_persist_form tag can be explicitly provided values to save e.g. as follows -
Code: Select all
<cms:db_persist_form 
    k_page_name='my-page-name'
    k_page_title='My Page Name'
    owner_id=k_user_id
/> 
In the sample code above we are setting two system fields and one custom field directly. The 'owner_id=k_user_id' part is what you are looking for (assuming the user accessing the form is logged-in).

Hope this helps.

Thanks KK, that was exactly what I was looking for :D
KK wrote: The cms:db_persist_form tag can be explicitly provided values to save e.g. as follows -
Code: Select all
<cms:db_persist_form 
    k_page_name='my-page-name'
    k_page_title='My Page Name'
    owner_id=k_user_id
/> 
In the sample code above we are setting two system fields and one custom field directly. The 'owner_id=k_user_id' part is what you are looking for (assuming the user accessing the form is logged-in).

I did this. The owner_id field was getting updated correctly with the member id, but while trying to get pages using custom field, it shows only pages with owner_id = 0 (instead of 9, which was the id of the user i was using.) Here's my code, please tell me what I'm doing wrong.

Code: Select all
<cms:pages masterpage='categories.php' custom_field='author_id=k_member_id'>
         <li><cms:show k_page_title /></li>
      </cms:pages>


I even tried putting <cms:show k_member_id /> instead of k_member_name. Still not working. On printing <cms:show k_member_id /> , I get the correct value as 9. But still this code only shows pages having author_id=0.

-Thanks in advance
14 posts Page 1 of 2