We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16834
    • 93 Posts
    OK. I will have a go, when I have worked out what your last comment actually meant! laugh

    Looks like I need to read up on extenders....

    L
      • 16834
      • 93 Posts
      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