FieldtypePageTable class

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.

Value type

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.

Getting and setting values
// 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');
Selectors

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');
Output / markup
// 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>";
}
Notes
  • 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_id is 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_id may be a single int or an array of ints when multiple templates are allowed.
  • Items added to a PageTableArray are validated against the field's configured template(s) and parent. Items that don't match are silently rejected by add().
  • When the owning page is deleted, trashed, or unpublished, the configured trashOnDelete, unpubOnTrash, and unpubOnUnpub settings 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: FieldtypePageTable only.
API reference: methods, hooks

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the FieldtypePageTable class also inherits all the methods and properties of: FieldtypeMulti, Fieldtype, WireData and Wire.

Show class?     Show args?       Only hookable?    

Common

NameReturnSummary 
FieldtypePageTable::exportConfigData(Field $field, array $data)
array

Export configuration values for external consumption

FieldtypePageTable::findOrphans(Page $page, Field $field)
PageTableArray

Return orphan pages that match the PageTable settings

 
FieldtypePageTable::formatValue(Page $page, Field $field, PageTableArray $value)
PageTableArray

Return a formatted PageTable value, which is essentially a new PageArray with hidden items removed

FieldtypePageTable::getBlankValue(Page $page, Field $field)
PageTableArray

Return a blank value used by a PageTable

 
FieldtypePageTable::getConfigInputfields(PageTableField $field)
InputfieldWrapper

Return configuration fields definable for each FieldtypePage

FieldtypePageTable::getDatabaseSchema(Field $field)
array

Return the database schema used by this Fieldtype

 
FieldtypePageTable::getFieldClass()
string

Get class name to use Field objects of this type (must be class that extends Field class)

 
FieldtypePageTable::getInputfield(Page $page, PageTableField $field)
Inputfield

Get the Inputfield used for input by PageTable

 
FieldtypePageTable::getMatchQuery($query, string $table, string $subfield, string $operator, mixed $value)
DatabaseQuery

Get the match query for page selection, delegated to FieldtypePage

 
FieldtypePageTable::getModuleInfo()
None 
FieldtypePageTable::getSelectorInfo(Field $field)
array

Get information used by selectors for querying this field

FieldtypePageTable::hookAfterReady(HookEvent $event)
None

Install our ajax lister at ready() time, if the conditions are right

 
FieldtypePageTable::hookPagesCloned(HookEvent $event)
None

Hook called when a page is cloned

 
FieldtypePageTable::hookPagesDelete(HookEvent $event)
None

Hook called when a page is deleted

 
FieldtypePageTable::hookPagesDeleteReady(HookEvent $event)
None

Hook called when a page is about to be deleted

 
FieldtypePageTable::hookPagesPublished(HookEvent $event)
None

Hook called when a page has been published

 
FieldtypePageTable::hookPagesTrashed(HookEvent $event)
None

Hook called when a page has been trashed

 
FieldtypePageTable::hookPagesUnpublished(HookEvent $event)
None

Hook called when a page has been unpublished

 
FieldtypePageTable::importConfigData(Field $field, array $data)
array

Convert an array of exported data to a format that will be understood internally (opposite of exportConfigData)

FieldtypePageTable::init()
None

Initialize the PageTable hooks

 
FieldtypePageTable::sanitizeValue(Page $page, Field $field, $value)
PageArray

Sanitize a PageTable value

 
FieldtypePageTable::sleepValue(Page $page, PageTableField $field, PageTableArray $value)
array

Prep a value for storage

FieldtypePageTable::wakeupValue(Page $page, PageTableField $field, array $value)
PageTableArray

Wake up a stored value

Additional methods and properties

In addition to the methods and properties above, FieldtypePageTable also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.259