* NoNDeSCRiPT How do I achieve this with XTScript or was it even achievable?
I want to list all .txt files from a folder then include them in a single page, instead of manually finding each file and xt:include'ing them one by one. My use cases for this would be for a quickscan reference for changelogs, a listing of all quotes randomly included in other pages or lengthy writings saved into separate .txt files and give the visitor an option to read all chapters at once.

Thanks in advance for all kind expert coders who would help me.
2018-02-12 14:53 · (0)
* Graham * NoNDeSCRiPT
You can use xt:include in the template of a xt:filelist provided that it is inside a xtscript
you can use the filter to load only files with a .txt extension
var $list = <xt:filelist sort_type="name" sort_dir="asc" folder="/text" template="&lt;xt:include file=&quot;/text/.file_name.&quot; /&gt;;&lt;hr /&gt;" per_page="" filter="*.txt" />
print $list

Copy code
2018-02-13 00:08 (edited 2018-02-13 03:01 by Graham ) · (1)
* NoNDeSCRiPT * Graham Thank you, sir. I still have a problem though. I figured including all contents somewhat produce a lengthy page. Is it possible to display only the first 250 characters of each file?
2018-02-14 04:30 · (0)
* Graham * NoNDeSCRiPT The problem is that all the data is still read as there is no provision in the include function to only include part of the data
so the best way is to have a second folder containing the shortened files using the same file names and do your includes from that with a link that sets a variable used to include the full versions and a back button that returns to the list of short versions
this uses the same page to display the long version and the list of short versions
this script also has provision for a paged list
<xt:include file="/text/{_$file|}" />
get_or_default __filelist_page;1
get file
var $url=<xt:url noquery="1" />
if $file
print <hr /><a href="$url?__filelist_page=$__filelist_page">Back</a>
var $list = <xt:filelist sort_type="name" sort_dir="asc" folder="/text_short" template="&lt;xt:include file=&quot;/text_short/.file_name.&quot; &gt; &lt;br /&gt;&lt;a href=&quot;$url?file=.file_name.&__filelist_page=$__filelist_page&quot;&gt; Read more &lt;/a&gt;&lt;hr /&gt;" per_page="3" />
print $list

Copy code
2018-02-14 08:05 (edited 2018-02-14 08:33 by Graham ) · (1)
* NoNDeSCRiPT * Graham Thanks, sir. I found it tedious to manually cut the text files one by one. I am trying to achieve creating snippets using the substring xtscript function but I can't seem to make it work properly.
2018-02-17 03:58 · (0)

Online: Guests: 1