Forum for discussing general topics related to Couch.
15 posts Page 2 of 2
@atisz, assuming the relation field defined in 'members/complaints.php' is named 'member', either of the following should fetch the complaints related to the current member -
Code: Select all
<cms:pages masterpage='members/complaints.php' custom_field="member=<cms:show k_member_name />"> 

Code: Select all
<cms:pages masterpage='members/complaints.php' custom_field="member=id(<cms:show k_member_id />)"> 

Does it help?
Adding to my reply above -
I'm also assuming that you are using 1.4.5RC1 or RC2 for the cms:pages to work with relation custom field. Else, as @cheesypoof suggested, you'll have to use cms:related_pages and cms:reverse_related_pages tags.
KK wrote: @atisz, assuming the relation field defined in 'members/complaints.php' is named 'member', either of the following should fetch the complaints related to the current member -
Code: Select all
<cms:pages masterpage='members/complaints.php' custom_field="member=<cms:show k_member_name />"> 

Code: Select all
<cms:pages masterpage='members/complaints.php' custom_field="member=id(<cms:show k_member_id />)"> 

Does it help?


Hi KK! Yes, it helps me, using the second code now I'm able to display user related content via relations ;) However, I don't understand something... using either of the above custom_field criteria means I'm saving the members name in the relation type editable? I'm asking this because I want to save the member's ID, and if you take a look inside the files I have sent to you, I'm using idmembru as relation type editable and also submitting the member id via idmembru in the databound form. Am I right? Then why is the member name displayed in Couch admin panel's relation field and why I'm filtering for member name?
I'll try explain :)

Internally, all relation fields store only IDs.
However, to make it easy for users to work with them they display the 'names' of the related pages instead of the stored IDs.

Normally you don't need to explicitly set values into the relation fields (the GUI suffices) but when this needs to be done (as in your case using databound form), we have to supply IDs as that is what is stored.

Relation fields are somewhat special in the sense that they store their data in their own tables - you saw this when you tried printing out <cms:show member /> and it outputted nothing.

We need to use either cms:related_pages/cms:reverse_related_pages to get the data out from these fields. With 1.4.5RC1, the 'custom_field' parameter of cms:pages has also begun to recognize the relation fields.

So when you used the following with cms:pages -
Code: Select all
custom_field="member=<cms:show k_member_name />" 

- the 'member' field was being given special treatment - you provide a 'name' and it gets resolved internally to the ID.

If you'd rather prefer to provide an explicit ID, it will require signalling this fact to cms:pages by using this syntax -
Code: Select all
custom_field="member=id(<cms:show k_member_id />)"

Bottom line is that the relation fields try to interface using the 'names' as that is easier than using IDs but internally everything is stored as IDs.

Hope this helps.
Ooooooooook KK, I get it now :mrgreen: Thanks for the detailed explanation.
All I have to do now is to change every single template which was implemented without relations, to use relations (comments, private messaging, free ads...)
15 posts Page 2 of 2
cron