Preview
in package
Somewhat complicated preview system which copies existing data into temporary tables, then renders the preview via a front-end method call
Table of Contents
Methods
- load() : int
- Loads a preview by creating temporary tables in SQL, calling a controller's _editSave method, and then calling a method it would normally use to display its (non-temporary) data
- run() : void
- Run a controller method using the preview data.
Methods
load()
Loads a preview by creating temporary tables in SQL, calling a controller's _editSave method, and then calling a method it would normally use to display its (non-temporary) data
public
static load(ManagedAdminController $ctlr, array<string|int, mixed> $tables[, int $record_id = 0 ]) : int
Parameters
- $ctlr : ManagedAdminController
-
The controller with the preview method
- $tables : array<string|int, mixed>
-
Tables to copy. The keys are the table names, and the values are WHERE clauses for data to copy across: use 0 to copy just the structure with no data, and 1 to copy all data; otherwise use an array of conditions (see Pdb::buildClause) The first table specified is the 'core' table which will contain the record which will be previewed. N.B. It's unnecessary to specify pages, page_revisions, or menu_groups here; they will be included automatically.
- $record_id : int = 0
-
ID of the main record, if it exists; 0 to insert a new record
Return values
int —The ID of the record (whether existing or newly inserted)
run()
Run a controller method using the preview data.
public
static run(Controller $ctlr, string $method[, array<string|int, mixed> $args = [] ]) : void
This injects the word 'PREVIEW' into the page title
Parameters
- $ctlr : Controller
- $method : string
-
The method to run
- $args : array<string|int, mixed> = []
-
Arguments for the method
Return values
void —This calls echo