Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

How to make Grav send a file as a download

Started by Thomas Green 7 years ago · 2 replies · 1391 views
7 years ago

I want to make a button that, when clicked, will send a download file of relevant data. I know you can do this in PHP - is there a way to it in Grav, or maybe an existing plugin, or will I have to write my own plugin?

7 years ago

Can you tell us a bit more? This might be possible without a plugin just by configuring media.yaml in your config:

  • you need to establish the link to the data document
  • if your data document is in a format not already listed in media.yaml, you may need to add it in system/config/media.yaml as described in the docs

Generally with a plain HTML link, it's the user's browser that will decide how to handle it (view or download).

It's hard to say more without trying to guess what you are doing.

7 years ago

Thanks Hughbris.

My club has an events page where event notices from many related clubs gets posted. The events editor, who's not techy at all, logs in and creates a new event page whenever she's told about an event. Every quarter, she publishes the current list in a paper-based newsletter, so she wants to be able to get the list in plain text format and drop it straight into the Word document for the newsletter.

So it's not a simple case of making a page with a button that links to a preset document. It needs to be a page whose template starts by compiling a list of the events, concatenated into a long string, and then that has to be delivered to her. I can do it easily enough by making a Form page that will email it to her, so that she can copy and paste it into the newsletter; but the system that we've been using allowed me to make a button that caused the list to be immediately downloaded. As she's a very busy woman she loved having a one-click system, and if I can reproduce it I'd like to.

Regrettably my skills and courage falter when I read the instructions for building a plugin - I'm not that much of a techie either. So if it's not possible without a plugin, she'll have to put up with the email version.

Hope that's clear! Thanks again for your interest.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 82 12 hours ago
General · by pamtbaau, 17 hours ago
1 55 16 hours ago
General · by Andy Miller, 1 day ago
0 45 1 day ago
General · by Marcel, 12 months ago
6 348 5 days ago
General · by Duc , 5 days ago
3 43 5 days ago