Forum for discussing general topics related to Couch.
15 posts Page 1 of 2
Hi guys!

I had just managed to set up a private messaging functionality in member area using messages.php clonable template and databound forms.
The template looks like this:
Code: Select all
<cms:template title='Messages' clonable='1'>
   <cms:editable name='senderid' required='1' type='text' />
   <cms:editable name='sendername' required='1' type='text' />
   <cms:editable name='message' required='1' type='textarea' />
   <cms:editable name='receiverid' required='1' type='text' />
</cms:template>

In list-view, the private messages are shown for the receiver members using:
Code: Select all
<cms:pages masterpage='members/messages.php' custom_field="receiverid==<cms:show k_member_id />">
... message info displayed here .....
</cms:pages>

Now I'm thinking it would be nice to allow members to access/display not only the received messages list, but sent messages list, too. So I'm wondering, could I use somehow a dropdown-box with 2 options: Received messages (preselected) and Sent messages in order to switch/filter the results accordingly? Any idea?

Thanks!
@atisz, though your solution will certainly work, I'd still suggest you use relations for storing the sender-id and receiver-id - that would be a more scalable solution.

Anyway, coming to your question - you can place the dropdown options in a form upon submission of which you can then use the submitted values to change the parameters of the cms:pages tag.

Please see viewtopic.php?f=8&t=7620 for a full example. I think it should be straight-forward for you to adapt that for your use-case.

Hope it helps.
KK wrote: @atisz, though your solution will certainly work, I'd still suggest you use relations for storing the sender-id and receiver-id - that would be a more scalable solution.

Thanks for the suggestion, KK! Honestly I've never used relations, I think it's time to give theme a try ;) Somewhere on the forum I had read something regarding performance, and your suggestion was to use relations because they speed up things, as I can remember.

KK wrote: Anyway, coming to your question - you can place the dropdown options in a form upon submission of which you can then use the submitted values to change the parameters of the cms:pages tag.
Please see viewtopic.php?f=8&t=7620 for a full example. I think it should be straight-forward for you to adapt that for your use-case.
Hope it helps.

Finally, I found a work-around to achieve what I wanted, it's a little messy solution but functional. I haven't used the above example, because I needed a simple way to switch between received and sent messages, and also needed to have displayed received messages on page access without further actions from user.
KK wrote: @atisz, though your solution will certainly work, I'd still suggest you use relations for storing the sender-id and receiver-id - that would be a more scalable solution.

Hm... it seems I don't get how relations work, or more clearly, I don't know how to store the IDs with relations. The docs don't have a sample for this, KK would you be so kind to explain/demonstrate how to do it the proper way?
Thanks.
I suggest you please take a look at the advanced tutorial - viewtopic.php?f=5&t=8981

It depends almost entirely on relations between the various entities (you may ignore the custom routes if you don't want to use them).

Do let me know if you still need any help.
Thank you KK for the suggestion. I tried to implement an easier stuff first, which needs saving only one member ID through relations. I had setup relations in complaints.php, databound form is used in send-complaints.php and sending the data is working .... but something strange is happening. In Couch admin I can see the sender name displayed in the drop-down, but in member area I can't filter the member related content. Using:
Code: Select all
<cms:pages masterpage='members/complaints.php' custom_field="member_id=<cms:show k_member_id />">
doesn't display anything, removing the custom_field criteria it does display the submited datas but obviously not only the member related ones. More strange, if I put
Code: Select all
<cms:show member_id />
between pages tag, it doesn't display anything, which makes me wonder how relations work? What am I missing here?
I'll need to take a look at how you have implemented everything to know what could be going wrong.

Could you please zip up all the relevant templates and snippets and post them as attachment?

Thanks,
KK wrote: I'll need to take a look at how you have implemented everything to know what could be going wrong.

Could you please zip up all the relevant templates and snippets and post them as attachment?

Thanks,


Hi KK! I have just sent you a PM with attached zip file. Thank you for taking a look ;)
You should be interfacing with relation type regions through the cms:related_pages and cms:reverse_related_pages tags, not cms:pages and the custom_field parameter.
@cheesypoof, v1.4.5RC1 onwards we can use cms:pages to access relational fields too - Enhanced cms:pages tag (viewtopic.php?f=5&t=8581)

@atisz, I'll study your code and get back. Thanks.
15 posts Page 1 of 2