Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
What's the least-crufty way to show the http response code?
I’d like to show the HTTP response code on a page. I’m curious if there’s a preferred way to do this.
We’ve got if_status
as a conditional check for a supplied error (HTTP 4xx
? Are there more?) code, and we’ve got error_status
that outputs the aforementioned code. An HTTP 200
is a non-error status in Textpattern terminology, and so my route in to achieve this is:
<txp:if_status not status="200">
<txp:error_status />
<txp:else />
200
</txp:if_status>
Am I missing a magical tag that just outputs the HTTP response without the conditional check?
For bonus Internet magic beans: does Textpattern core emit any other non-error HTTP response codes over and above HTTP 200
?
Offline
Re: What's the least-crufty way to show the http response code?
That’s pretty much the best way. As far as I can recall, 200 is the only non-error we emit:
$codes = array(
'200' => 'OK',
'301' => 'Moved Permanently',
'302' => 'Found',
'303' => 'See Other',
'304' => 'Not Modified',
'307' => 'Temporary Redirect',
'308' => 'Permanent Redirect',
'401' => 'Unauthorized',
'403' => 'Forbidden',
'404' => 'Not Found',
'410' => 'Gone',
'414' => 'Request-URI Too Long',
'451' => 'Unavailable For Legal Reasons',
'500' => 'Internal Server Error',
'501' => 'Not Implemented',
'503' => 'Service Unavailable'
);
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: What's the least-crufty way to show the http response code?
Probably <txp:error_status default="200" />
?
Offline
Re: What's the least-crufty way to show the http response code?
etc wrote #340848:
Probably
<txp:error_status default="200" />
?
Oooh yeah, forgot that default
was a global attribute. Good hack.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: What's the least-crufty way to show the http response code?
Offline