Published blog and Preview screens
The Blog page that visitors get to see is created by a simple Ditto call with its configuration in a file:
[[Ditto?config=`blog`]]
Note that this site uses the PHx plugin, so the call is cached and the page uncacheable, to make pagination work if needed. On a site that doesn't use the PHx plugin, the Ditto call will be uncached: [!Ditto?config=`blog`!] The config file, ditto/configs/blog.config.php, checks for parameters in the URL query string as well as setting the Ditto parameters.
The blog.first.tpl template chunk is used for the listing unless the query string "?template=preview" is appended to the URL.
If the query string specifies tags, the posts-per-page parameter is not set, so all posts with relevant tags will be listed regardless of pagination settings, using the same template chunk. Preview items are not displayed, because they are unpublished documents.
If the query string does include "?template=preview" (set up by clicking the Preview button in the main Create Post form), only the document specified by the ID which is also in the query string is displayed, and the blog.preview.tpl template chunk is used. This shows both the Summary and the Content fields as they will appear in the relevant published pages. It also generates forms with hidden fields and buttons to re-edit the item, publish it immediately, delete it or view the full post.
Never use the Back button to continue editing a preview - use the Edit button. Using Back will create a new item with duplicate content.
blog.config.php
if ($_REQUEST['template'] !== 'preview') {
if (empty($_REQUEST['tags'])) {
$display = '3' ;
}
$tpl = 'blog.first.tpl' ;
$extenders = array('summary') ;
$tagData = 'pwTags' ;
$tagDelimiter = ',' ;
$tagDisplayDelimiter = ', ' ;
$orderBy = array('parsed'=>array(), 'custom'=>array(), 'unparsed'=>'pkDate DESC, menuindex DESC');
} else {
$documents = $_REQUEST['id'];
$showPublishedOnly = 0;
$display = '1' ;
$tpl = 'blog.preview.tpl' ;
$extenders = array('summary') ;
$tagData = 'pwTags' ;
$tagDelimiter = ',' ;
$tagDisplayDelimiter = ', ' ;
}
?>
blog.first.tpl
<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">([[Jot?action=`count-comments` &docid=`[+id+]`]] comments) [+link+]</p>
</div>
blog.preview.tpl
<input type="hidden" name="docId" value="[+id+]" />
<input type="hidden" name="tags" value="[+pwTags+]" />
<input type="hidden" name="returnId" value = "685" />
<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+]