Hi,
This is something that seems like it should be easy and I feel like I am missing something, but I can't seem to get it working.
What we are trying to do is take the contents of a text file generated on another system and display it as part of a page in matrix.
The way we have done this previously (with images not text) was to create an asset, set unrestricted access to yes, then manipulate the file directly on the file system. This method is working fine this time around as well and if you go directly to the text file asset url you see the updated file.
The problem is that I can't seem to get the contents of the text file to show up if I do anything other than access it directly via its _data based url. If I use an asset listing then %asset_contents_raw% returns nothing, and if I use a nested content div then it also returns nothing.
Is there a way to get the contents of a txt file to display, or is there a better way to get the data into matrix so that it can be displayed and sent as part of the contents of a form submission email?
Ryan
You can't nest File-based assets into content anywhere as they are always treated as binary data (even text files). You would need to put the text data into a page within Matrix and update it from there.
Thanks Greg.
What would be the best way to get the text data updated in a page automatically? The best thing I can think of right now is to use a wget script to update the data through the front end. Is there some Matrix based way to do the same thing in a more robust way?
Ryan
Hi Ryan,
To import external content we use a cron job and import script. The script creates a standard page with the content in it. We use a trigger to expire the page after a certain amount of time (depending on how often new pages are imported). The standard pages get listed in a asset listing. All our weather pages work this way (the content is XML, but the idea is the same).
You could set the script to do nothing if there is no content, or perhaps even create a hash based on the content of the text page (we do this somewhere on our site), save it and compare it to avoid unnecessary updates.
cheers,
Richard
Yeah, I think a script is the way to go. Updating the content of a page via a script is fairly easy, especially if the page ID does not change.
You might even be able to do this with the existing XML import format. If you put something like this into a file:
<action>
<action_id>set_contents</action_id>
<action_type>set_attribute_value</action_type>
<asset>[WYSIWYG CELL ASSET ID]</asset>
<attribute>html</attribute>
<value>[CONTENT HERE]</value>
<action>
You can try running it using the scripts/import/import_from_xml.php script. Haven't tried it myself, but I'd start there.