$page->status() method

Get or set current status

  • When manipulating status, you may prefer to use the $page->addStatus() and $page->removeStatus() methods instead.

  • Use this status() method when you want to set multiple statuses at once, or when you want to get status rather than set it.

  • You can also get or set status directly, by manipulating the $page->status property.

Example

// Get the current status as bitmask
$status = $page->status();

// Get an array of status names assigned to page
$statuses = $page->status(true);

// Set status by Page constant bitmask
$page->status(Page::statusHidden | Page::statusUnpublished);

// Set status by name
$page->status('unpublished');

// Set status by names
$page->status(['hidden', 'unpublished']); 

Usage

// basic usage
$int = $page->status();

// usage with all arguments
$int = $page->status($value = false, $status = null);

Arguments

NameType(s)Description
value (optional)bool, int

Optionally specify one of the following:

  • true (boolean): To return an array of status names (indexed by status number).
  • integer|string|array: Status number(s) or status name(s) to set the current page status (same as $page->status = $value)
status (optional)int, null

If you specified true for first argument, optionally specify status value you want to use (if not the current).

Return value

int array Page

If setting status, $this is returned. If getting status: current status or array of status names is returned.

See Also


$page methods and properties

API reference based on ProcessWire core version 3.0.214

Twitter updates

    Error retrieving Twitter status

Latest news

  • ProcessWire Weekly #472
    In the 472nd issue of ProcessWire Weekly we'll check out ProcessWire 3.0.218, the very first add-on WireCache module, a new third party FormBuilder add-on module, and more. Read on!
    Weekly.pw / 28 May 2023
  • A look at the new Page Edit Restore module
    The new Page Edit Restore module helps to prevent page edits in the admin from getting lost when the user’s session is lost. This post covers it in detail.
    Blog / 12 May 2023
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH