ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Write to file

October 30, 2010 9:40pm

Subscribe [3]
  • #1 / Oct 30, 2010 9:40pm

    timj

    80 posts

    I have an application where it would be useful to write certain channel entries to a standing flat file on a server (filename.txt).  If the channel entry is edited through the CP, those changes also write to the file.  All new entries and all edits will overwrite to that flat file.  To make matters even more complex, it would be ideal if html special chars were grepped into high ASCII.  Right now I am using LOW’s excellent Replace plugin to handle the latter.

    Can someone describe how this might be achieved?

  • #2 / Oct 31, 2010 8:05pm

    the3mus1can

    426 posts

    You could write an extension and use the entry_submission_end hook to write the data to the file. See http://ellislab.com/expressionengine/user-guide/development/extension_hooks/api/channel_entries/index.html#entry_submission_end

  • #3 / Nov 03, 2010 11:27am

    Sean Delaney

    64 posts

    >You could write an extension and use the entry_submission_end hook to write the data to the file. See http://ellislab.com/expressionengine/user-guide/development/extension_hooks/api/channel_entries/index.html#entry_submission_end

    Can you please provide an example for when you would call this hook?

    I’m looking to do something similar and write entries to an XML file on the server, but how would I link my code that this hook?

    Sean

  • #4 / Nov 03, 2010 3:19pm

    Focus Lab Dev Team

    1129 posts

    I’m looking to do something similar and write entries to an XML file on the server…

    Did you know you could create dynamic XML templates in EE? That might be an easier route to take with this.

    What’s the purpose of writing the file?

  • #5 / Nov 03, 2010 3:23pm

    Sean Delaney

    64 posts

    We have a SWF file that gets its info from an XML file and the client wants to be able to update the info from CMS.

  • #6 / Nov 03, 2010 3:25pm

    Sean Delaney

    64 posts

    I’m looking to do something similar and write entries to an XML file on the server…

    Did you know you could create dynamic XML templates in EE? That might be an easier route to take with this.

    How?

  • #7 / Nov 03, 2010 3:29pm

    Focus Lab Dev Team

    1129 posts

    I’ve created a number of dynamic SWF/XML interactions with EE. You don’t need to bother writing to files.

    http://ellislab.com/expressionengine/user-guide/cp/design/templates/new_template.html

    Let me know if you need help

  • #8 / Nov 03, 2010 3:46pm

    Sean Delaney

    64 posts

    So how does this work then?

    How can I control the XML structure?

  • #9 / Nov 03, 2010 3:48pm

    Focus Lab Dev Team

    1129 posts

    How can I control the XML structure?

    You create the structure like you’d create any HTML page. Consider this question: “How do I control the HTML markup structure?”

    You write it. Nothing special to it really. I imagine that since you’re working with a specific Flash file you need to structure it to the Flash needs. I’m not sure though.

  • #10 / Nov 03, 2010 3:52pm

    Sean Delaney

    64 posts

    Ah right ok.  Sorry I wasn’t understanding what you meant. 

    I’ve just created a new template, pasted in some XML tags and viewed the rendered output and it was fine - just what I need.

    I now can create a new channel for Flash content and use {exp:channel:entries} to build my XML…

    However, in SWFObject javascript attributes array I point to content.xml.  I guess I now just point to http://domain.tld/template_group/template/ ?

  • #11 / Nov 03, 2010 4:12pm

    Sean Delaney

    64 posts

    @Erik Reagan

    Thank you BTW - this is a GREAT solution!!!!!

    Sean

  • #12 / Nov 03, 2010 4:23pm

    Focus Lab Dev Team

    1129 posts

    However, in SWFObject javascript attributes array I point to content.xml.  I guess I now just point to http://domain.tld/template_group/template/ ?

    Exactly. Just point to the template and also remember you can pass dynamic info just like in normal EE templates.

  • #13 / Nov 03, 2010 4:28pm

    Sean Delaney

    64 posts

    Yes, I have it all working with the SWF now.

    Once again thank you so much for the help!

  • #14 / Nov 03, 2010 4:29pm

    Focus Lab Dev Team

    1129 posts

    Glad to help!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases