Page 1 of 1
[Solved] include a text file in a page
Posted: Thu Oct 27, 2011 8:21 pm
by trainer
Hello,
I would like to include a text file in some of my pages.
What is the correct way to do this?
I have tried UDTs but I'm not getting anywhere.
I've also tried it with a URL and variations of the path and also an absolute path - but still no luck.
Is there another method? (not UDT maybe...?)
I'd appreciate any advice.

Re: include a text file in a page
Posted: Thu Oct 27, 2011 9:52 pm
by Wishbone
The UDT:
Code: Select all
echo("<pre>");
readfile($params['file']);
echo("</pre>");
The call:
Code: Select all
{read_text_file file=stylesheet.css}
http://teamwishbone.com/1941/index.php?page=text-file
Re: include a text file in a page
Posted: Thu Oct 27, 2011 9:53 pm
by calguy1000
Re: include a text file in a page
Posted: Thu Oct 27, 2011 9:57 pm
by Wishbone
That works, but ignores new lines... I tried
{'stylesheet.css'|readfile|nl2br}
but for some reason, it's not converting the new lines to line breaks
Re: include a text file in a page
Posted: Thu Oct 27, 2011 10:00 pm
by calguy1000
This works fine:
Code: Select all
<pre>{'stylesheet.css'|readfile}</pre>
Re: include a text file in a page
Posted: Thu Oct 27, 2011 10:17 pm
by calguy1000
Though, hypothetically speaking, a geshi wrapper module would be sexy.
Does somebody wanna write one?
Re: include a text file in a page
Posted: Thu Oct 27, 2011 10:30 pm
by Wishbone
calguy1000 wrote:Though, hypothetically speaking, a geshi wrapper module would be sexy.
Does somebody wanna write one?
I had to look that up... Sounds like it would be a fun module to make... No code formatting modules in the Forge?
Re: include a text file in a page
Posted: Thu Oct 27, 2011 10:33 pm
by Wishbone
It looks like there is the UpHyperlight module, but I have no idea how it compares to GeSHi.
http://dev.cmsmadesimple.org/projects/uphyperlight
Re: include a text file in a page
Posted: Fri Oct 28, 2011 10:40 am
by trainer
It works!
Thanks a lot guys - I really appreciate your responses
BTW, would I use this method for including other cmsms pages?
Or is there a different (proper) way of doing that?
Re: include a text file in a page
Posted: Fri Oct 28, 2011 4:40 pm
by Wishbone
No.. CMSMS pages aren't files. Take a look at the CGSimpleSmarty module for easy ways to include other pages content.
Re: include a text file in a page
Posted: Fri Oct 28, 2011 7:58 pm
by trainer
Will do - thanks again.
