torchbox/wagtail — pull request #192 by gasman (2014-04-08 15:48:01+00:00)
Title: Support multiple page modes on preview

This change allows pages to define multiple display modes for use when previewing; these are presented as options within the page editor interface. For example, a page with a form on it might be viewable in two modes: the standard view that displays the form, and a thankyou page shown post-submission; this allows editors to preview both modes of the page.

I tested this on wagtaildemo with this rather frivolous addition to the EventPage class:

def get_page_modes(self):
return [
('standard', 'Standard view'),
('upside-down', 'Upside down'),
]

def show_as_mode(self, mode):
if mode == 'upside-down':
response = super(EventPage, self).show_as_mode(mode)
response.render()
response.content += """"""
return response
else:
return super(EventPage, self).show_as_mode(mode)

This results in a 'Preview' menu as shown below; also shown for comparison is the new default view, where only one display mode is available and thus the Preview option is presented as a single button. @davecranwell, does this fit OK with our design guidelines?

Multiple modes available:
![screen shot 2014-04-08 at 16 25 39](https://cloud.githubusercontent.com/assets/85097/2645625/9a986f16-bf34-11e3-98fa-dbf716dc804f.png)

Only one mode available:
![screen shot 2014-04-08 at 16 25 29](https://cloud.githubusercontent.com/assets/85097/2645629/a8524528-bf34-11e3-984e-d0a1620a4ab6.png)