Accept fields that render XML node structure

B-Prod - August 18, 2009 - 08:59
Project:Views Bonus Pack
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

To export the taxonomy tree via XML, including the taxonomy tree structure:

<vocabulary>
  <name>Voc 1</name>
  <terms>
    <name>Term 1</name>
    <name>Term 2</name>
  <terms>
</vocabulary>

It is necessary to modify the function template_preprocess_views_bonus_export_xml in file views_bonus_export.theme.inc.

I check for each rendered field if there is some display options for list display in the view and if the list type is "XML", to avoid having the < and > characters escaped.

I needed that for export the UUID taxonomy tree (@see http://drupal.org/project/uuid - the views handler has not been suggested in any issue for the moment, still testing) for each node. But it may be useful for any module that implements a views field handler which renders a list, so it could propose the "XML" option in its field display options:

    $form['type'] = array(
      '#type' => 'radios',
      '#title' => t('Display type'),
      '#help' => t('The option <em>XML structure</em> renders a XML node tree that can be used with <em>views bonus</em> module.'),
      '#options' => array(
        'ul'  => t('Unordered list'),
        'ol'  => t('Ordered list'),
        'xml' => t('XML structure'),
      ),
      '#default_value' => $this->options['type'],
    );

AttachmentSize
views_bonus_export.theme.inc.patch1.11 KB

#1

killes@www.drop.org - August 19, 2009 - 20:17
Status:patch (to be ported)» needs review

changing status.

#2

neclimdul - August 24, 2009 - 16:09

I really like this! I'm trying to figure out if there's some way we can use this to help other CCK methods like multiple text fields expand their information.

#3

neclimdul - August 24, 2009 - 23:06

+++ views_bonus_export.theme.inc 18 Aug 2009 08:39:37 -0000
@@ -59,12 +59,18 @@
+      $field_options = $view->display[$view->current_display]->display_options['fields'][$field];

Getting a lot of notices from this line

Do you have anything from the uuid side I'd be able to look at? I think it might help me understand if there's a better way we could fix this.

PS - I knew I'd regret mangling the out here. :P

#4

neclimdul - August 24, 2009 - 23:13

Sorry, notice is "Undefined index: fields"

#5

B-Prod - August 25, 2009 - 14:08

In fact, it is used with fields that add a custom option 'xml' in the display options list, through options_form().

Please find my modified version of UUID module. The standard version does not implement views, and I didn't proposed it yet before my first proposal (http://drupal.org/node/551152) is agreed or not.

The xml tree is implemented for 'All terms UUIDs', within uuid_handler_field_term_node_tid.inc file.

For another view handler, it could be more simple to call parent::options_form(&$form, &$form_state) then modify the $form['type'] options, but for UUIDs I did not want to have options like separator, exclude or alter...

I hope you will find a better way to handle this. If you need some help, I will be involved.

AttachmentSize
uuid.zip 15.44 KB

#6

gausarts - September 27, 2009 - 11:50

Subscribing. Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.