Additional documentation notes for template configuration from the ProcessWire admin.

URLs Tab

Allow Page Numbers

If checked, pages using this template will be pagination enabled and able to accept page number URL segments in the form 'page123', where '123' may be any positive number.

For example, a request URL of /widgets/page3 automatically sets the $input->pageNum to be 3. This is used for pagination and should only be enabled for templates that support pagination.

Note that page numbers start at 1 (not 0). If combined with URL Segments (see next section), then the page number must be the last part of the URL.

The maximum number of allowed page numbers can be configured with the $config->maxPageNum property. The default value is 999.

The prefix used for page numbers can be configured with the $config->pageNumUrlPrefix property. The default value is "page". This can be set on a per-language basis from the LanguageSupportPageNames module settings.

Allow URL Segments

Templates may optionally serve URL path segments below that of the page(s) using it. For example, you may want a page with path /path/to/page/ to also handle requests for /path/to/page/segment1/ or /path/to/page/segment1/segment2/. By default, ProcessWire will throw a 404 error when such a URL is accessed. But if you want ProcessWire to render the page instead, check the box to enable URL segments. You can then manually check the URL segments from your template file to respond to them.

The number of URL segment levels supported after the page URL is configurable with the $config->maxUrlSegments property, but the default 4 (i.e. /path/to/page/1/2/3/4/).

URL segments must follow the same format as page names. Meaning, they can be any combination of lowercase ASCII letters (a-z), numbers (0-9), dashes, underscores and periods.

Accessing URL segments from the API

You can access the URL segments from your template API code by referencing the $input->urlSegment(n) function or $input->urlSegment[n] property (replacing [n] with 1, 2, 3, etc.).

You may also access the $input->urlSegmentStr property, which returns the current path of URL segments. Note that the $input->urlSegmentStr property does not have leading or trailing slashes, i.e. a/b/c rather than /a/b/c/.

For example, given the URL /path/to/page/a/b/c/, where /path/to/page/ is the page path, and a/b/c are the segments: $input->urlSegment1 is "a", $input->urlSegment2 is "b", and $input->urlSegment3 is "c".

If your template file receives unknown URL segments, a best practice is to abort the request by throwing a 404 error. The API code to do this is: throw new Wire404Exception(); Alternatively, you may specify exactly which URL segments to allow – see the section below on which URL segments to allow. This often eliminates the need to throw a 404 since your template will not receive unknown URL segments.

See also: Tutorial on how to use URL segments

Which URL Segments do you want to allow?

Leave blank to allow any, or enter one segment, segment path (i.e. a/b/c) or regular expression (i.e. regex:photo[0-9]+) per line. Segments are compared against the $input->urlSegmentStr property. Slashes may be used if specifying multiple segments, but omit slashes from the beginning and ending. If specifying a regular expression then prepend the word regex: to the line, followed by your non-delimited pcre-compatible regular expression. See below for an example:


The above would allow these URLs to be processed by the template file:

  • /path/to/page/photos/
  • /path/to/page/photos/new/
  • /path/to/page/photos/photo3/ (replacing 3 with any number)
  • /path/to/page/export-json/
  • /path/to/page/export-xml/

Latest news

  • ProcessWire Weekly #510
    In the 510th issue of ProcessWire Weekly we'll check out ProcessWire 3.0.236, introduce a new third party module PageFinder Depth from Robin Sallis, and more. Read on! / 17 February 2024
  • Using date range fields in ProcessWire
    This week we'll take a detailed look at the newest addition to the ProFields set of modules: the Date Range Fieldtype and Inputfield.
    Blog / 24 November 2023
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani