Thank-you. Your suggestion worked. However, I was using the [[ ]] style purposely because I was using the following snippet to dynamically include the BlogHeader chunk (the ditto call from my previous post) if the page had a template variable "blogPageIndicator" set (gets set whenever a blog is created):
[!ConditionalContent? &isIncluded=`[*blogPageIndicator*]` &contentTpl=`BlogHeader` !]
ConditionalContent snippet
<?php
/*
* Description
* Output content if included flag is set.
* Parameters
* &isIncluded - set to 1 to include, 0 to exclude.
* &isExcluded - set to 1 to exclude, 0 to include.
* &contentTpl - the content chunk to include if it is included.
* Notes:
* This uses evalSnippets (see http://modxcms.com/forums/index.php?topic=22914.0)
*/
if ($isIncluded == '1' || $isExcluded == '0') {
return $modx->evalSnippets($modx->getChunk($contentTpl));
}
?>
On rethinking the solution I have created a purpose specific snippet that works correctly:
[!OnlyForBlogPageHeader? &isBlogPage=`[*blogPageIndicator*]` !]
OnlyForBlogPageHeader snippet
<?php
/*
* Description
* Output content if blog flag is set.
* Parameters
* &isBlogPage- set to 1 to include, 0 to exclude.
*/
if ($isBlogPage == '1') {
$params = array();
$params['documents'] = $modx->documentIdentifier;
$params['tpl'] = 'BlogInfo';
$params['dateFormat'] = '%A %e %B %Y';
$params['tagData'] = 'documentTags';
$params['tagDelimiter'] = ',';
echo $modx->runSnippet('Ditto', $params);
}
?>
Why did I do this? Because I wanted to ’decorate’ the blog page.
I could have used the chunk {{BlogHeader}} directly in the blog page content and then the Ditto "removeChunk" parameter. However, this requires that each existing blog page have the BlogHeader chunk inserted. My thinking at the time was when the site matured I did not want to have to modify every blog page for future additions. Now I realise that two chunks would probably work as well - BlogHeader and BlogFooter.
The ’decorater’ solution allows the template to dictate different header/footer chunks, so there is more flexibility. So it probably depends on how much flexibilty in displaying the blog pages is required.
Another solution would be to have two templates - almost identical, one for blog pages, one for the main site. I am somewhat averse to the duplication though