Previews before publication
It is very handy to have see how an item will look before making it public. In PubKit, this is achieved by a Preview button in the item creation form.
Beware! An unpublished item is created when you ask for a preview. To go back and continue editing it, use the Edit button. Never use the browser's Back button, which may result in creation of another new item.

A template variable pkPreviewFlag is set by the preview request, and the same page as for published output is called, but with "template=preview" attached as a query string in the URL. The Ditto call (or other snippet) in the output page must detect this and load an alternative template. The examples use a config file with Ditto to process the query string and load the appropriate template chunk. You don't have to put all the parameters into the config file, only the ones that may differ between previews and published output.
[!Ditto?parents=`16` &config=`pkNews` &orderBy=`pkDate DESC, menuindex DESC` ]]
Content of ditto/configs/pkNews.config.php:
// news.config.php
// config file for News section of pubKit demo site
// switch tpl chunk according for previews
// more parameters in snippet call for handy adjustment
$extenders=array('summary');
$truncLen = 600;
$tagData = 'pkNews';
if ($_REQUEST['template'] !== 'preview') {
$tpl = 'pk.news.main.tpl';
} else {
$documents = $_REQUEST['docId'];
$showPublishedOnly = 0;
$tpl = 'pk.news.preview.tpl' ;
}
?>
The preview template chunk starts with a form to generate buttons for Edit, Publish and Delete, with the necessary data in hidden fields to feed back to the editing snippet. (Note that PubKit can use alias names as well as document IDs to specify action and destination pages for forms.)
Below the form, you can use the same formats as the published output to see how your item (and its summary version) will look if it is published.
<input type="hidden" name="docId" value="[+id+]" />
<input type="hidden" name="preview" value="1" />
<input type="hidden" name="tags" value="[+pkBlogTags+]" />
<input type="hidden" name="returnId" value = "pkdemo-post-manage" />
<input type="submit" name="command" value="edit" />
<input type="submit" name="command" value="delete" />
<input type="submit" name="command" value="publish" />
</form>
<div class="blogItem">
<h4>[+pagetitle+]</h4>
<h5>[+pkDate:date=`%d %b %y`+] <span class="links">[+tagLinks+]</span></h5>
<h3><a href="[+url+]">[+longtitle+]</a></h3>
<div class="blog_intro">[+summary+]</div>
<p class="more">[+link+]</p>
</div>
<hr />
[+content+]