We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22019
    • 390 Posts
    Not sure I’m going about this the right way.

    I have a form, which writes to a custom table. I can query and list the custom table, and a snippet then sends tab-formatted output as a file to the user. While I still have that output in tab-delimited form, I want to write a file to the filesystem, but I’m getting a little confused as to how to go about this.

    I see that there is a modFile object, but the path appears to be set in modFileSystemResource, and I’m not really sure how/if to instantiate either - is it as simple as

    $file = newObject('modFile');

    If so, how do I tell it the other stuff I need to tell it (path/filename)?

    [As an aside, I’ve tried going a completely different way, and creating a resource instead of a file (which I know how to do from form input), but there are three problems here - I can’t seem to set ’text’ as a content_type, it won’t preview or publish at the right location, and I eventually want the list of these created files / resources to show up in a list, and Wayfinder doesn’t seem to like text resources.]
      Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
      • 22019
      • 390 Posts
      Ok - it transpires content_type is an integer, and once I set that to ’3’ then I can output a txt file.
      It also transpires that if you add a second word to the alias, it can output the url correctly. Not entirely sure why.

      [Still would like to understand how to use a modFile object, but for now I’ll go with what works]
        Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
        • 28215
        • 4,149 Posts
        odeclas, check out the core/model/modx/processors/browser/ files. Those processors use the modFile/modDirectory classes quite a bit; modFileHandler->make($path) creates a modFile or modDirectory object from a path. I’ll get you more info on them in a rtfm.modx.com doc later this week.
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com