We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    My bad, I copied the code from inside a class (fixed above).

    Your fix is correct, but in order to create a resource in the front end using the processor, you need to be logged in as a user who has the permission to do so. When you preview from the Manager, you're not logged in to the web context. You'll see all docs, but you won't have many of the necessary permissions in the web context. If you log in as the admin (using the Login snippet), it should work.

    BTW, have you looked at NewsPublisher? It will do most of the heavy lifting for you (though you'll still need a front-end login). It will also (by default) forward you to the new resource.


    ------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using.
    MODX info for everyone: http://bobsguides.com/modx.html
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 38677
      • 21 Posts
      Thanks, Bob. I see. Makes sense.

      Any idea why the other approach doesn't work? I have checked directly in the site_content table and the dynamically created record seems identical to the resources created through the MODX manager. I also don't really see any difference in the record once I save it through MODX (after which it works fine).

      Thanks for the help.
        • 3749
        • 24,544 Posts
        If you are trying to forward the user to a new resource, it's probably a cache issue. The new resources is not yet in the documentmap, so you can't forward to it. When you create a resource in the Manager, MODX clears the cache, which refreshes the documentmap. To do it yourself (before the forward), you can use this to refresh the documentmap:

        $modx->reloadContext('web');


        or the more generic:

        $modx->reloadContext($modx->context->get('key'));



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 38677
          • 21 Posts
          Every day I learn something new about MODX. wink

          Thanks, Bob. You're a star.
            • 3749
            • 24,544 Posts
            Don't thank me until it works. wink

            I had the same problem for a long, long time until OpenGeek gave me the solution.


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting