philleepflorence / directus-8-extensions

A Collection of all Extensions added to Directus 8
27 stars 4 forks source link

Export to CSV #1

Open yagobski opened 4 years ago

yagobski commented 4 years ago

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

philleepflorence commented 4 years ago

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

philleepflorence commented 4 years ago

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.

yagobski commented 4 years ago

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 notifications@github.com 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 .

philleepflorence commented 4 years ago

The previous comment is for an endpoint...

yagobski commented 4 years ago

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

philleepflorence commented 4 years ago

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.

yagobski commented 4 years ago

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 commented 4 years ago

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?

philleepflorence commented 4 years ago

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

MoeVai commented 4 years ago

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?

philleepflorence commented 4 years ago

@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