I have a CSV export attachment that's destined to get migrated back in with Migrate (after an external process adds more data).

So I'd like the CSV header to have strings that are in machine-friendly format, that is, lowercase, numbers, and underscores only.

On the other hand, with the page display that the CSV is attached to, it would be nice to keep this with human-readable labels.

And finally, I really don't want to have to override all the fields on the CSV attachment display just to change the field labels -- that will be an extra maintenance burden if fields are added in future.

Hence I think a simple feature to add would be an option for the CSV export to convert the labels to machine name format. Patch coming!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Active » Needs review
FileSize
2.21 KB
efpapado’s picture

Hello,

If I get it well, your patch does not use the actual machine name of the fields, but rather gets the field label and converts the string in a way that is compatible with machine names.
But wouldn't it be better to use the machine name itself?

efpapado’s picture

Shreya Shetty’s picture

This is a very good feature to be included in Views data Export. Sio that it gives the flexibility for the user to replace the header with the machine name of the field. Please include this patch in the next release. I have tested the patch it works fine.

efpapado’s picture

Can you attach also an interdiff?

Shreya Shetty’s picture

Am extremely sorry @efpapado that I created a patch which was same as your patch. My bad when I applied the patch it wasn't getting applied so thought of creating a patch on the latest version.
But now I have made some improvements which provide the flexibility for the user to select the field which will be having the machine name of the field if the field is not selected it will be having the label as it was working previously. Thank You for the previous patch.
Hope this feature gets committed soon so that the user get more options for the header labels. Providing interdiff for the same.

szeidler’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the patch #3 is working like charm and I use that approach for every big XML and JSON export, where I don't want to handle the labels manually.

Moving forward to RTBC.

wheretoplaygames’s picture

I've applied these patches, but do not see the any results. Do i have to scrap my current view and create a new one?

Testing the one with the checkbox to force field names. Where should i be seeing this checkbox?

szeidler’s picture

FileSize
276.59 KB

You don't need to recreate the view.

  1. Go to the view display
  2. Click on Format -> Settings
  3. There you should find the new checkbox to be enabled

You might need to clear your the cache before.

wheretoplaygames’s picture

Thank you, szeidler! Your image helped me because i was looking in the wrong place for the checkbox.