Page 1 of 1

Output News template to a file?

Posted: Tue May 02, 2023 1:54 pm
by reinhardmohr
Hi,
could anybody help me / give me a hint with the News module?
I am neither a Smarty specialist nor a programmer – so I have been looking around for a long time.
Problem / question:

I need to output a news template to write a file to the file system on the server.
I can fetch a file with smarty, no problem. But I could nowhere find how to write a file with smarty. The idea is to use a news template to output the latest 10 news – and then write the output to a file in a directory on the server so that it can be read and / or downloaded by another application or website.

I am using CMSms 2.2.16 and the latest module updates.
Thanks for helping!

Reinhard

Re: Output News template to a file?

Posted: Tue May 02, 2023 1:59 pm
by DIGI3
This tutorial is for creating an rss feed from cgblog, but I think a similar process would work for what you're trying to achieve. It doesn't create a physical file on the server, but a page that acts as a file - so it would be accessible by url but not a local file path. You'll need to adapt the tutorial to your needs: https://cmscanbesimple.org/blog/create- ... t-a-module

Re: Output News template to a file?

Posted: Thu May 04, 2023 7:15 am
by reinhardmohr
Hi, Digi3,

thanks for the quick and helpful response!
I knew this blog of Rolf‘s – but I had no idea that it would solve my problem! Thank you!

A bit more information: I needed to output 10 news of the news module as a json file that could be read for further processing in an app. While I could do the formatting of the news I could not output it with the ending .json.
Rolf‘s blog now gave me the important clue: Under the "Navigation" tab there is a field where I can just type in a url to my desire. So I typed in "page.json". And now the output of the news module can be read as nothing but a json-file (actually a json-formatted page). This works – great!

Thanks again for helping
and for making CMSms and all the great modules!
Reinhard