FieldtypePageTable
Stores references to a group of pages that are edited inline (in a modal window) from the page editor
Items are real pages in the ProcessWire page tree — either as children of the page being edited, or under a separately configured parent page. Unlike Repeater, PageTable items have their own URLs and are independently addressable via the pages API.
PageTableArray (extends PageArray). Each item is a regular Page using whichever
template(s) are configured on the field.
Formatted value (output formatting on) excludes hidden and unpublished items. Unformatted value includes all items regardless of status.
// Iterate items
foreach($page->pagetable_field as $item) {
echo $item->title;
echo $item->some_field;
}
// Add a new item (template and parent determined from field configuration)
$item = $page->pagetable_field->getNewItem();
$item->title = 'New item';
$item->save();
$page->save('pagetable_field');
// Add an existing page as an item
// ($item must have correct template and parent or it will be refused)
$item = $pages->get('/path/to/item/');
$page->pagetable_field->add($item);
$page->save('pagetable_field');
// Remove an item from the field value (does not delete the page)
$page->pagetable_field->remove($item);
$page->save('pagetable_field');
// Delete an item page permanently
$pages->delete($item);
$page->save('pagetable_field');PageTable supports subfield matching, delegating to FieldtypePage for query resolution.
Direct field-value matching (e.g. pagetable_field=1234) is not supported — use subfields.
// Pages that have at least one item with a matching title
$pages->find('pagetable_field.title*=keyword');
// Match by a custom field on the items
$pages->find('pagetable_field.some_field=value');
// Match by item template
$pages->find('pagetable_field.template=product');// Iterate and output
foreach($page->pagetable_field as $item) {
echo "<h3>{$item->title}</h3>";
echo "<p>{$item->body}</p>";
}
// Template syntax via each()
echo $page->pagetable_field->each("<div><h3>{title}</h3><p>{body}</p></div>");
// Link directly to an item page (items have their own URLs)
foreach($page->pagetable_field as $item) {
echo "<a href='$item->url'>$item->title</a>";
}- PageTable items are real pages with URLs, unlike Repeater items which are stored in a
hidden admin structure. Items can be found and accessed via
$pages->find()independently. - If
parent_idis configured on the field, all items live under that shared parent page. If not set, items are created as children of the page being edited. template_idmay be a single int or an array of ints when multiple templates are allowed.- Items added to a
PageTableArrayare validated against the field's configured template(s) and parent. Items that don't match are silently rejected byadd(). - When the owning page is deleted, trashed, or unpublished, the configured
trashOnDelete,unpubOnTrash, andunpubOnUnpubsettings control what happens to the item pages. - Cloning a page with a PageTable field automatically clones all of its PageTable items.
- Database columns:
pages_id INT,data INT(item page ID),sort INT. - Compatible fieldtypes:
Fieldtypeonly.Page Table
Please see the PageTable Fieldtype for usage instructions. Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the In addition to the methods and properties above, PageTableField also inherits the methods and properties of these classes:PageTableField is used instead of Field for fields of type FieldtypePageTableField class also inherits all the methods and properties of: Field, WireData and Wire.Properties
Name Return Summary PageTableField::autoTrash int bool Deprecated, replaced by $trashOnDelete. PageTableField::columns string Column field names to display in the admin table view (one per line). PageTableField::nameFormat string Auto-format string for naming newly created item pages. PageTableField::noclose int If 1, keep the item editor open after saving rather than closing it. PageTableField::parent_id int Parent page ID where items are stored, or 0 to use the page being edited as parent. PageTableField::sortfields string Comma-separated field names to auto-sort items by (e.g. 'title' or '-date'). Leave blank for manual drag-and-drop sort. PageTableField::template_id int array Template ID (or array of IDs) that PageTable items must use. PageTableField::trashOnDelete int What to do with items when the owning page is permanently deleted: 0=nothing, 1=trash items, 2=delete items. PageTableField::unpubOnTrash int What to do with items when the owning page is trashed: 0=nothing, 1=unpublish items. PageTableField::unpubOnUnpub int What to do with items when the owning page is unpublished: 0=nothing, 1=unpublish items, 2=hide items. Additional methods and properties
API reference based on ProcessWire core version 3.0.261