Go to main content

If status

Contents

Syntax

<txp:if_status>

The if_status tag is a conditional tag and always used as an opening and closing pair, like this…

<txp:if_status>
    …conditional statement…
</txp:if_status>

The tag will execute the contained statements depending on the requested page’s HTTP status condition. Normal pages result in a status code of ‘200’, while missing pages set Textpattern’s status to ‘404’.

This tag provides a method of sharing one page template between common pages and error pages, but including different output depending on the page’s HTTP status.

Attributes

Tag will accept the following attributes (case-sensitive) as well as the global attributes :

status="number"
Numerical HTTP status code.
Default: 200 (OK).

Examples

Example 1: Conditionally display text on missing pages

<txp:if_status status="404">
    <h2>The page you requested could not be found.</h2>
</txp:if_status>

If you notice any kind of problem with this page's construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)