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
    When do you see that error? When you try to edit the page or when you try to view it in the front end?
      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
      • 43509
      • 24 Posts
      When I save a new post (in Articles) from the frontend, in a non default context.
      The post is regularly saved, but page redirection is wrong (it seems it does not consider friendly urls).
      When I try to edit an existing post also the redirection mechanism does not work: it saves and then redirects to homepage (same redirection problem).

      As I was saying, I have two contexts: "web" the default one, and "it" (for Italian pages), configured through Babels and .htaccess.
      Everything works as expected in "web". I got the errors in the "it" context, creating a new post inside Articles.
        • 3749
        • 24,544 Posts
        First, there is a System Setting you should check: allow_forward_across_contexts.

        In case that's not it, I just took a look at the NewsPublisher class code and saw something that might help.

        Edit this file: \core\components\newspublisher\model\newspublisher\newspublisher.class.php

        Around line 1524 (in the forward() method), try changing this line:

        $goToUrl = $this->modx->makeUrl($postId);



        To this:

        $goToUrl = $this->modx->makeUrl($postId, "", "", "full");




        Clear the site cache before testing.

          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
          • 43509
          • 24 Posts
          Thanx for your help.

          Actually the first suggestion "allow_forward_across_contexts" solves the "503 error", but not the redirect problem: now, when I add a new post and click "submit" no more error, it simply redirects to home page (because it seems it is not able to resolve, with friendly urls, the address of the newly added post "http://mysite/it/index.php?id=314".
          It should actually be something like "http://mysite/it/blog/2013/05/17/test/").

          Correction to line 1524 has no addictional effects.


          Thank you!
            • 3749
            • 24,544 Posts
            Some other things to try:

            Comment out lines 1529 and 1530:

            // $controller = $this->modx->getOption('request_controller',null,'index.php');
            // $goToUrl = $controller . '?id=' . $postId;


            If that doesn't do it, try changing line 1524 to this:

            $goToUrl = $this->modx->makeUrl($postId, $this->resource->get('context_key'), "", "full");


            Let me know if anything works. [ed. note: BobRay last edited this post 10 years, 10 months ago.]
              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
              • 43509
              • 24 Posts
              Both suggestions, one at a time, do not redirect correctly: url remains "http://domain/it/NewsPublisher.html", no errors by the way, just a blank page (in the "content" display area).
              Implementing both together redirects again to something like "http://domain/it/index.php?id=319", forcing the site to display its home page.
                • 3749
                • 24,544 Posts
                I should have asked this before. Are you creating a new Resource or editing an existing one when this happens?

                  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
                  • 43509
                  • 24 Posts
                  The same on both sides.
                  Could it be due to a particular .htaccess configuration maybe?
                    • 3749
                    • 24,544 Posts
                    It's possible, but I doubt it. I think it's more likely to be a problem with cross-context forwarding with makeUrl().

                    Could you try this: Comment out those first two lines I mentioned above, then hard-code the correct context into the makeUrl() line like this:

                    $goToUrl = $this->modx->makeUrl($postId, 'web', "", "full");

                    That might help determine where it's going wrong.
                      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
                      • 43509
                      • 24 Posts
                      I hard coded the line this way:
                      $goToUrl = $this->modx->makeUrl($postId, 'web', "", "full");
                      

                      (the default "web" context works great).

                      With that mod in place the "edit existing post" side is improved: after submit, it correctly redirects to the right resource.
                      No luck with the "post new resource" instead... still blank page.

                      By the way, thank you for your support!