Download content text files


#1

Probably not a big thing, but I can’t figure it out: Is it possible to show a list of all content text files of all the grandchildren of a page? So one could download them as .txt with all the content in it. I have the code to get all files, but don’t know how to access the content.txt – thanks a lot in advance !

<?php
$files = page('event')->grandChildren()->files();
foreach($files as $file):
?>
<a href="<?= $file->url() ?>" ><?= $file->filename() ?></a>
<?php endforeach ?>

#2

files(). only gets the. media files, not the textfile.

You can get the path to the content. text files using $page->textfile().

https://getkirby.com/docs/cheatsheet/page/textfile

But note that this method returns a string, not a file object, so you. can call url() on it and the text files are not directly accessible via the browser. What is your use. case?


#3

I have a form for people to send in texts and I create subpages from it after the cookbook recipe Creating pages from frontend. For the person who organises the texts it would be nice to be able to download those textfiles somehow from a page without accessing the content folder on the server. Is something like that possible?


#4

I think it should be possible to create a download link somehow, I’d try with a route.