Just in case someone else needs to do a similar thing.....
I found the page ’Adding TV Widgets without hacking the core’ at
http://wiki.modxcms.com/index.php/Adding_TV_Widgets_without_hacking_the_core
This I adapted as follows (please note that my tagging TV is ’docTags’ and ’tagLink2’ is the chunk that creates the "Related Pages" section in the right hand column of my page):
Snippet ’sidebarWidget’
<?php
// sidebarWidget snippet
// parameters:
// &tvname - Set the TV name to be used, my tagging TV is docTags
$TVname = isset($tv)?$tv:'docTags';
// fetch the output array of the TV
if( $TVarray = $modx->getTemplateVarOutput(array($TVname)) ){
#TV output is in index [$TVname][1]
$tvOutput = $TVarray[$TVname][1];
if(empty($tvOutput)) return ''; //bail out if the page is not tagged
// This page is tagged.
// I want to call my Related Pages chunk
$chunkOutput = $modx->getChunk("tagLink2");
return $chunkOutput;
}
return '';
?>
My template calls [[sidebarWidget]] at the relevent position. This creates a "Related Pages" navigation module only on those pages that are tagged. If a page has no tag then the section is not displayed.
Lee