Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
4 posts Page 1 of 1
I needed a quick way to set a field value on the server side without going through DataBound forms or anything like that.

Also, I liked the ease of use the 'get_custom_field' function provided, so I wrote something up to do the other side of that function, update a selected record given a masterpage and (when appropriate) page.

Example:
Code: Select all
<cms:set_custom_field var='last_page' val=k_page_name masterpage='members/index.php' page=k_member_name />

The code above updates a field named 'last_page' on the currently logged in member (using the couch provided members module) with the page name of the current page.

Hope someone else finds this useful and I would love some feedback on anything I might have missed.

Attachments

Excellent work :) Thank you.

May I add that as an alternative, we can also use the following -
Code: Select all
<cms:db_persist _masterpage='members/index.php' _page_id=k_member_id  _mode='edit'
    last_page=k_page_name
/> 

The cms:db_persist tag above can set multiple fields in a single go (but requires a page_id instead of page_name).
You can find a bit more about it here - viewtopic.php?f=2&t=8301&p=15104&#p15104

Hope to see more contribution from you, @temp10293 :)
Thanks again.
Thanks for the compliment KK. I didn't know about the db_persist function (still relatively new to couch), but it looks like exactly what I needed, with more complexity and flexibility.

One thing I did notice was updating repeatable fields is a little more complex than other fields, because of the way the data is stored (as a php serialized string). Does db_persist handle those types of fields?
updating repeatable fields is a little more complex than other fields, because of the way the data is stored (as a php serialized string). Does db_persist handle those types of fields?

cms:db_persist, as seen in the example above, is limited to 'string' inputs. As we discussed in another thread, repeatable regions would be difficult to represent as simple strings and so, I am afraid, updating repeatable regions without the use of forms is still not possible.
4 posts Page 1 of 1