We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13218
    • 134 Posts
    Hi,
    how do i manually set the header for a resource? I have some special multilingual setup, so i can't just $mod->sendErrorPage(). I would like to send my 404 Page without changing the called URI and change the http status to 404.
    Do i just use:
    <?php
    header("HTTP/1.0 404 Not Found");
    ?>


    ?

    Thanks,
    Marc [ed. note: itWillBeOk last edited this post 14 years, 9 months ago.]
      @itWilllBeOK
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      ..I would like to send my 404 Page without changing the called URI..
      Use sendForward: http://rtfm.modx.com/display/revolution20/modX.sendForward

      You can specify the second property like
      array('response_code' => 'HTTP/1.0 404 Not Found')

      to give it a 404 error response or whatever you want to give it.

      sendForward expects a resource ID. If you need to add more info to the page, simply use modX::setPlaceholder and call that (uncached) on your target page.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 13218
        • 134 Posts
        Thanks Mark.

        I actually thought of sendForward already, but since there's this rather complex setup including a cUrl-call, i'm not quite sure it will work. But if it does it certainly is the easiest way.
          @itWilllBeOK
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          When you sendForward the process for the current page halts, so just do what you need to do before that.. it shouldn't matter what you do.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 13218
            • 134 Posts
            Well, it mostly really doesn't seem to matter what i do. You got that right.

            But this actually did work, was a bit tricky though. Just setting the header would have been much easier. But then if i just don't know how to do it, whatever works is always easiest.

            Cheers.
              @itWilllBeOK