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
    I’m trying to finish up the Revo version of News Publisher. The Evo version forwards the user to the newly created resource.

    I can make that work in Revo, but only if I clear the cache before forwarding. AFAIK, in Evo it worked whether you cleared the cache or not (since clearcache is an option).

    In Revo, even if I save the resource, then make the URL myself, sendRedirect() fails unless the cache is cleared first. It doesn’t seem like this should be necessary, and in a site where lots of users are creating resources in the front end (e.g., a simple blog), it would be a serious performance hit if the cache is cleared every time someone posts. I would have thought that if the resource isn’t found in the cache during the sendRedirect() process, it would be retrieved from the DB.

    Is there some trick I haven’t hit on that will make this work without clearing the cache?
      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
      • 26903
      • 1,336 Posts
      The resource create processor clears the cache with this code :-
      if (!empty($scriptProperties['syncsite']) || !empty($scriptProperties['clearCache'])) {
          /* empty cache */
          $cacheManager= $modx->getCacheManager();
          $cacheManager->clearCache(array (
                  "{$resource->context_key}/",
              ),
              array(
                  'objects' => array('modResource', 'modContext', 'modTemplateVarResource'),
                  'publishing' => true
              )
          );
      }


      on resource creation, so it seems it may be necessary.
        Use MODx, or the cat gets it!
        • 3749
        • 24,544 Posts
        Thanks. I’m already doing that, but it looks like the problem might be the aliasmap and I wonder if I could just update that myself or if it could be updated in the resource’s save() method.

          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
          • 3749
          • 24,544 Posts
          Updating the aliasMap doesn’t seem to help, so I guess clearing the cache is necessary, though I don’t see why from a design standpoint since the resource is theoretically in the DB at this point.
            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
            • 26903
            • 1,336 Posts
            When Frontpage creates a page it doesn’t auto forward to the new page, you have to go there yourself but this did work, at least with id’s, I didn’t try with aliases though. I also noticed that if the page is created in a container that Wayfinder is producing links from the link to the new page didn’t show up until I cleared the site cache, refreshed the page and the link appeared. I didn’t have time at the time to look at this further, from your experiences looks as though I need to clear the cache from my creation code also.
              Use MODx, or the cat gets it!
              • 3749
              • 24,544 Posts
              It looks to me like there’s no way to generate a FURL of any kind before the aliasMap is updated.
                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
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: BobRay at Nov 27, 2010, 09:03 AM

                It looks to me like there’s no way to generate a FURL of any kind before the aliasMap is updated.
                That’s correct; the context cache MUST be regenerated before the FURL can be generated or routed properly. This is the way it has always been, even in Evo. My advice was always to clear the cache, but you should also provide a landing page to redirect to when save is completed successfully, because even with the cache cleared and regenerated, the new values will not be available until a new request is made.
                  • 3749
                  • 24,544 Posts
                  sendRedirect() to the newly create page works for me if the cache is cleared. Are you saying that it’s not reliable? It’s how NewsPublisher has worked for a long time.
                    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
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Quote from: BobRay at Nov 27, 2010, 01:06 PM

                    sendRedirect() to the newly create page works for me if the cache is cleared. Are you saying that it’s not reliable? It’s how NewsPublisher has worked for a long time.
                    Only if you manually reload that data into memory; remember, the first thing that happens in a request is that the cached settings are loaded. This does not happen again in the request cycle.
                      • 3749
                      • 24,544 Posts
                      Quote from: OpenGeek at Nov 27, 2010, 05:34 PM

                      Quote from: BobRay at Nov 27, 2010, 01:06 PM

                      sendRedirect() to the newly create page works for me if the cache is cleared. Are you saying that it’s not reliable? It’s how NewsPublisher has worked for a long time.
                      Only if you manually reload that data into memory; remember, the first thing that happens in a request is that the cached settings are loaded. This does not happen again in the request cycle.

                      Sorry, I’m not following. Doesn’t sendRedirect() initiate a new request cycle that would reload the cache (including the new doc) if it had been cleared?
                        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