Admin pages preview

For reference only.


The 'Preview page' button is $_POST['submit2'] which actions at the top of index.php in admin. Amongst other things, the action must:

  1. before showing the preview page, check whether a page title was entered,
  2. before showing the preview page, check whether any content was entered, and
  3. make sure the preview doesn't lose the content of index.php when the preview page 'edit' link is clicked to go back to it.
How 'preview' works

(assuming a page title and content were entered)

  1. The 'Preview page' button is pressed.
  2. If a file preview.txt exists, it is deleted.
  3. A temporary new text file preview.txt is created.
  4. The content is written to it.
  5. A 'header' location 'https://example.com/preview?page=page-title' is set, replacing index.php.
  6. inc/edit.php in the page being previewed GETs the value of '?page' from the URL parameter
  7. ... with the return 'edit' link as 'https:example.com/index.php?page=page-title&mode=preview'

The return 'edit' link re-opens index.php with the page title and content unchanged. index.php does this by:

  1. $mode = $_GET['mode'] which = 'preview'
  2. Populating the content box with the contents of 'preview.txt'
  3. then deleting 'preview.txt' ready for the next preview.

See information

Page last modified: 16 July, 2024
Search | Legal | Qwwwik

Info