hello,
i m using a filed collection (contact person) in my node , in service views - field configuration if i choose :
Services Raw formatter i get this :
<contact_person is_array="true">
<item><value>29</value><revision_id>29</revision_id></item>
<item><value>28</value><revision_id>28</revision_id></item>
</contact_person>
with Filed Collection items formatter i get this :
<contact_person is_array="true"><item><div class="field-collection-view clearfix view-mode-full"><div class="entity entity-field-collection-item field-collection-item-field-labo-contact clearfix" about="/lieu-orginal/fr/field-collection/field-labo-contact/29" typeof="">
<div class="content">
<div class="field field-name-field-field-labo-c-title field-type-text field-label-above"><div class="field-label">Title: </div><div class="field-items"><div class="field-item even">Prof</div></div></div><div class="field field-name-field-labo-f-name field-type-text field-label-above"><div class="field-label">First name: </div><div class="field-items"><div class="field-item even">vall</div></div></div><div class="field field-name-field-labo-l-name field-type-text field-label-above"><div class="field-label">Last name: </div><div class="field-items"><div class="field-item even">gyns</div></div></div><div class="field field-name-field-lab-c-function field-type-text field-label-above"><div class="field-label">Function / Domaine: </div><div class="field-items"><div class="field-item even">Professor</div></div></div><div class="field field-name-field-lab-c-email field-type-email field-label-above"><div class="field-label">Email: </div><div class="field-items"><div class="field-item even"><a href="mailto:student@fundp.ac.be">student@fundp.ac.be</a></div></div></div><div class="field field-name-field-labo-c-phone field-type-phone-number field-label-above"><div class="field-label">Phone number: </div><div class="field-items"><div class="field-item even">+32-81726358</div></div></div> </div>
</div>
</div></item><item><div class="field-collection-view clearfix view-mode-full field-collection-view-final"><div class="entity entity-field-collection-item field-collection-item-field-labo-contact clearfix" about="/lieu-orginal/fr/field-collection/field-labo-contact/28" typeof="">
<div class="content">
<div class="field field-name-field-field-labo-c-title field-type-text field-label-above"><div class="field-label">Title: </div><div class="field-items"><div class="field-item even">Mme.</div></div></div><div class="field field-name-field-labo-f-name field-type-text field-label-above"><div class="field-label">First name: </div><div class="field-items"><div class="field-item even">benjamine</div></div></div><div class="field field-name-field-labo-l-name field-type-text field-label-above"><div class="field-label">Last name: </div><div class="field-items"><div class="field-item even">Dallas</div></div></div><div class="field field-name-field-lab-c-function field-type-text field-label-above"><div class="field-label">Function / Domaine: </div><div class="field-items"><div class="field-item even">chercheur</div></div></div><div class="field field-name-field-lab-c-email field-type-email field-label-above"><div class="field-label">Email: </div><div class="field-items"><div class="field-item even"><a href="mailto:g.mda@fundp.ac.be">g.mda@fundp.ac.be</a></div></div></div><div class="field field-name-field-labo-c-phone field-type-phone-number field-label-above"><div class="field-label">Phone number: </div><div class="field-items"><div class="field-item even">+32-81724473</div></div></div> </div>
</div>
</div></item></contact_person>
any solution to have an xml formatter for field collection with different tag ;
thx for your help
Comments
Comment #1
ajlow commentedI have the same issue as well.
Comment #2
ajlow commentedI actually had a brief look and from what I can see, this is occurring due to the preview() method within the views_plugin_display_services.inc:
As a test, changing the:
return '<pre>' . var_export(services_views_execute_view(NULL, $this->view, $this->display->id), TRUE) . '</pre>';to:
return json_encode(services_views_execute_view(NULL, $this->view, $this->display->id));did display the JSON version however:
Can someone explain how the preview() method is called or which hook it is used and what would be a better way to return the JSON/XML representation of the field collection? I'm quite new at Drupal development...
Comment #3
Dante Blitz commentedAnyone know how to make this spit out valid xml of the content?
Comment #4
KeyboardCowboyThis is my attempt at supporting field collections. What this will do is add a View Mode to your field collections called 'Services' that allows you to define data values for your entity to be embedded into the view.
hook_services_field_collection_data_alter($field_data, $entity, $field_name)In more detail, this patch fixes the Services Raw formatter for entity field displays, adds a custom view mode, adds extra settings to the entity field formatter and processes field collections in the view as separate entities.
Comment #5
MoonLightDragon commented#4 Works Fine, but after patching services views, we got many Undefined index warnings like this:
Notice: Undefined variable: element_key in services_views_execute_view() (line 171 of /sites/all/modules/services_views/services_views.resource.inc).
Notice: Undefined index: text_processing in _text_sanitize() (line 319 of /modules/field/modules/text/text.module).
Notice: Undefined index: text_processing in _text_sanitize() (line 319 of /modules/field/modules/text/text.module).
Notice: Undefined index: services in services_views_execute_view() (line 168 of /sites/all/modules/services_views/services_views.resource.inc).
Notice: Undefined index: services in services_views_execute_view() (line 168 of /sites/all/modules/services_views/services_views.resource.inc).
Notice: Undefined index: services in services_views_execute_view() (line 168 of /sites/all/modules/services_views/services_views.resource.inc).
Any Idea how to fix this?
Comment #6
KeyboardCowboyThanks for the report, @Andiff.
I didn't see those on my install. It looks like it is expecting the "services" view mode and not finding it. Have you tried clearing Drupal's cache?
I'll try to reproduce it on my end today. Any other information you can provide about your setup and the steps you took are greatly appreciated and can help speed things up.
Comment #7
bessone commentedThe patch on #4 is for 7.x-1.0-beta2 or -dev?
Comment #8
KeyboardCowboyPatches should always be rolled against -dev branches so maintainers can (hopefully) apply them to their most up-to-date codebase.
Comment #9
ajlow commentedIf you use the latest dev release of Services Views, the patch will fail for the last hunk: services_views.resource.inc. This is due to the change in code for beta4. Tried to look for beta3 but from the releases, I could only see beta 2! It is fairly simple to manually implement the rejected patch.
I followed the steps in #4. One thing I found out is that the "Skip empty values" setting will still skip empty values even if you un-selected the checkbox.
Comment #10
odegard commentedApplied the patch in #4 to beta2, followed the procedure proveded by KeyboardCowboy and it works.
Updated to recently released services views 1.0, applied the patch manually and it works.
Solving this problem in any other way is very difficult, this patch is a huge timesaver. Thanks KeyboardCowboy!
Comment #11
odegard commentedI'm getting many notices from this (first) line in the patch:
Notice: Undefined index: data_element_key i services_views_execute_view() etc. etc.There is nothing being broken since the second line above checks $element_key. It seems that this part of the code handles the case where you specify the value key in the services view mode. What's weird is that my custom keys show up just fine, so I guess I'm wrong in my thinking somewhere.
Comment #12
ajlow commentedFirst of all, thank you KeyboardCowboy for your help on this! :)
This works great however I now have a curious problem. For my field collection, I have an image field that previously was only set to only one image. Now, due to changes in requirements, I need to have multiple images for this image field.
I've set the field to have multiple images and have put in test images, however when I ran my service, only last image added in is being returned.
Is there a way to allow multiple images to be returned?
Thank you!
Comment #13
dom. commentedHi !
That works perfectly ! Thanks a lot. This is really a must-have in Services Views module.
Comment #14
dom. commentedPS: just a very little change to get it work with current 1.x version attached.
Comment #16
kylebrowning commentedComment #18
liquidcms commentedsadly i can't re-open this but it shouldn't be closed until committed somewhere.. which i don't think it is.