PagesExportImport::arrayToPage()
Import an array of page data to a new Page (or update existing page)
Provided array ($a) must originate from the pageToArray() method format.
Returns a Page on success or a NullPage on failure. Errors, warnings and messages related to the import can be pulled from $page->errors()
, $page->warnings()
and $page->messages()
.
The following options may be used with the $options
argument:
commit
(bool): Commit/save the changes now? Default:true Specify false to perform a test run.update
(bool): Allow update of existing pages? Default:truecreate
(bool): Allow creation of new pages? Default:trueparent
(Page|string|int): Parent Page, path or ID. Omit to use import data Default:0template
(Template|string|int): Template object, name or ID. Omit to use import data Default:0fieldNames
(array): Import only these field names, or omit to use all import data Default:[]changeStatus
(bool): Allow status to be changed aon existing pages? Default:truechangeSort
(bool): Allow sort and sortfield to be changed on existing pages? Default:truereplaceTemplates
(array): Array of import-data template name to replacement template name Default:[]replaceFields
(array): Array of import-data field name to replacement field name Default:[]originalRootUrl
(string): Original root URL (not including hostname)originalHost
(string): Original hostname
The following options are for future use and not currently applicable:
changeTemplate
(bool): Allow template to be changed on existing pages? Default:falsechangeParent
(bool): Allow parent to be changed on existing pages? Default:falsechangeName
(bool): Allow name to be changed on existing pages? Default:falsereplaceParents
(array): Array of import-data parent path to replacement parent path Default:[]
Usage
// basic usage
$page = $pagesExportImport->arrayToPage(array $a);
// usage with all arguments
$page = $pagesExportImport->arrayToPage(array $a, array $options = []);
PagesExportImport methods and properties
API reference based on ProcessWire core version 3.0.251