directus-8-extensions icon indicating copy to clipboard operation
directus-8-extensions copied to clipboard

Export to CSV

Open yagobski opened this issue 5 years ago • 11 comments

Hi I want to use your code to add Export to CSV of a collection and i don't know how to use your code. Can you please give me an exemple. Thanks

yagobski avatar Feb 18 '20 17:02 yagobski

Are you trying to do this via an endpoint or you want to extend the codebase of Directus?

philleepflorence avatar Feb 18 '20 18:02 philleepflorence

i. Entry Point

https://github.com/philleepflorence/directus-8-extensions/blob/master/endpoints/csv/endpoints.php

ii. Controllers

https://github.com/philleepflorence/directus-8-extensions/tree/master/endpoints/csv/controllers

iii. Helper

https://github.com/philleepflorence/directus-8-extensions/blob/master/helpers/csv.php

All the helper files used within all methods are included in the helper directory.

philleepflorence avatar Feb 18 '20 18:02 philleepflorence

Iam trying to do it using endpoint but If u have any other solution it will be great thanks

On Tue, Feb 18, 2020 at 19:05 Philleep Florence [email protected] wrote:

Are you trying to do this via an endpoint or you want to extend the codebase of Directus?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/philleepflorence/directus-8-extensions/issues/1?email_source=notifications&email_token=AABV6NFQF3JNUEBNF2EESBDRDQPPTA5CNFSM4KXJPUA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMDADJI#issuecomment-587596197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABV6NHYKTL7Y6RQJAZVNT3RDQPPTANCNFSM4KXJPUAQ .

yagobski avatar Feb 18 '20 20:02 yagobski

The previous comment is for an endpoint...

philleepflorence avatar Feb 18 '20 20:02 philleepflorence

Do you have an exemple of the request with some fake parameters? This is exactly what i need.

yagobski avatar Feb 18 '20 20:02 yagobski

Using PostMan these are some pre-defined parameters.

For Export:

access_token:{{access_token}}
debug:{{debug}}
collection:{{collection}}
params[fields]:*.*
params[status]:published
params[limit]:-1
path:csv/collections/{{collection}}.csv
options[humanize]:true

For Import:

access_token:{{access_token}}
debug:{{debug}}
collection:{{collection}}

you will also need a csv file sent via post (form-data).

There should be comments on the required parameters in the helper methods.

philleepflorence avatar Feb 18 '20 20:02 philleepflorence

Thanks a lot for your help. This will be useful for other users too. Export/Import is the missed feature for directus.

AccessToken is required if iam using cookies?

yagobski avatar Feb 18 '20 20:02 yagobski

Have you plan to add a button on the vuejs interface like that people can click on Export and it will export the data using your service?

yagobski avatar Feb 18 '20 20:02 yagobski

There is a potential addition to the Core Directus after there is a lift on features freeze.

philleepflorence avatar Feb 18 '20 20:02 philleepflorence

Hi, i am not a developer and i don't have experience with PHP and i really want to use this, any video tutorial, please?

MoeVai avatar Sep 10 '20 07:09 MoeVai

@MoeVai Unfortunately, there is no Video Tutorial, but I do have a blog that tries to explain some of it... But, you will need to dabble in PHP to implement, there is no Plug and Play type installation just yet.

https://www.philleepflorence.com/blog

philleepflorence avatar Sep 11 '20 15:09 philleepflorence