We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    Hi BobRay and thanks for your continued support on this. Here is my chunk code containing the call:

    <div id="post-[[+id]]" class="post-[[+id]] post hentry category-latest-news tag-tag3 tag-tag5 tag-tag7">
    <div class="post-top">
    <div class="post-date"><span class="day">[[+publishedon:strtotime:date=`%d`]]</span> <span class="month">[[+publishedon:strtotime:date=`%b`]]</span> <span class="year">[[+publishedon:strtotime:date=`%Y`]]</span></div>
    
    <h4><a title="Permanent Link to [[+pagetitle]]" href="[[~[[+id]]]]" rel="bookmark">[[+pagetitle]]</a></h4>
    </div>
    <div class="entry"><a href="[[~[[+id]]]]"><img class="alignleft" title="[[+tv.news_image_title]]" src="[[+tv.news_image]]" alt="" width="610" height="380" /></a> [[+content:ellipsis=`350`]] <a class="more-link" href="[[~[[+id]]]]">Read the rest of this entry »</a></div>
    <div class="postmetadata">Tags: [[!MyTags? &tags=`[[*tags]]` &target=`19`]]</div>
    </div>


    I have then create a snippet called MyTags as follows:

    <?php
    /* MyTags snippet */
     
    $tags = $modx->getOption('tags', $scriptProperties, '', true);
    $target = $modx->getOption('target', $scriptProperties, '0', true);
    if (empty($tags)) {
        return '';
    }
     
    $fields = array(
        'tags' => $tags,
        'tagKey' => 'tags',
        'target' => $target,
    );
     
    return $modx->runSnippet('tolinks', $fields);


    I have ammended the last line from toLinks, to tolinks. The tolinks snippet is the one from the repository. When I view my source code I get the following:

    <div class="postmetadata">Tags: </div>
    </div>


    The current page (blog) has an empty 'tags' TV as I am trying to display the tags from the 'resources' that are pulled in by my getResources call

    Regards, DS
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 3749
      • 24,544 Posts
      Aha,

      Try changing it to this:

      [[+tv.tags]]


      As I said earlier, using * will always get the value from the current page, not the one being processed by the aggregator snippet.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7527
        • 437 Posts
        Ok I replaced my original code with:

        <div id="post-[[+id]]" class="post-[[+id]] post hentry category-latest-news tag-tag3 tag-tag5 tag-tag7">
        <div class="post-top">
        <div class="post-date"><span class="day">[[+publishedon:strtotime:date=`%d`]]</span> <span class="month">[[+publishedon:strtotime:date=`%b`]]</span> <span class="year">[[+publishedon:strtotime:date=`%Y`]]</span></div>
         
        <h4><a title="Permanent Link to [[+pagetitle]]" href="[[~[[+id]]]]" rel="bookmark">[[+pagetitle]]</a></h4>
        </div>
        <div class="entry"><a href="[[~[[+id]]]]"><img class="alignleft" title="[[+tv.news_image_title]]" src="[[+tv.news_image]]" alt="" width="610" height="380" /></a> [[+content:ellipsis=`350`]] <a class="more-link" href="[[~[[+id]]]]">Read the rest of this entry »</a></div>
        <div class="postmetadata">Tags: [[!MyTags? &tags=`[[+tv.tags]]` &target=`19`]]</div>
        </div>


        Still no luck unfortunately. Maybe as you said before it is too many things nested within each other for a simple solution.
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 3749
          • 24,544 Posts
          What are you using to get the aggregated resources? getResources?

          Post the tag you're using for that snippet.

          also, try just using this (if the TV is named 'tags').

          [[+tags]]
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 7527
            • 437 Posts
            I amended the call to this

            <div class="postmetadata">Tags: [[+tv.tags]]</div>
            </div>


            and it shows the tags, but they are not linked. If I remove the 'tv.' I get nothing back. This is my aggregated call:

            [[!getPage@newsPaging? &elementClass=`modSnippet` &element=`getResources` &showHidden=`1` &tpl=`newsTpl` &limit=`2` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &parents=`[[*id]]` &hideContainers=`1` &pageLimit=`5` &pageNavVar=`page.nav` ]]

              www.PawsForWildlife.co.uk
              www.Borntobrick.co.uk
              • 3749
              • 24,544 Posts
              I really don't see why it wouldn't work with this version:

              <div class="postmetadata">Tags: [[!MyTags? &tags=`[[+tv.tags]]` &target=`19`]]</div>


              But, as you say, it's pretty deeply nested. You have a snippet call (toLinks) inside a snippet call (MyTags) inside chunk used in a snippet call (getResources) inside a snippet call (getPage) inside a template. If the getPage call is also in a chunk, it's even deeper.

              I can think of another way to do it, but it's more complicated and might not work any better.

              <div class="postmetadata">Tags: [[!MyTags? &tags=`[[+id]]` &target=`19`]]</div>


              <?php
              /* MyTags snippet */
              
              $tvId = 12; // Change this to the ID of your tags TV
              
              $docId = $modx->getOption('id', $scriptProperties, '', true);
              $target = $modx->getOption('target', $scriptProperties, '0', true);
              if (empty($docId)) {
                  return 'No doc Id';
              }
              
              $tvObj = $modx->getObject('modTemplateVar', $tvId);
              if ($tvObj) {
                  return 'No Such TV';
              }
              $tags = $tvObj->renderOutput($docId);
              
              $fields = array(
                  'tags' => $tags,
                  'tagKey' => 'tags',
                  'target' => $target,
              );
              
              return $modx->runSnippet('tolinks', $fields);
              
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting