We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I have a problem, TV's of a site are not shown when using getResources or pdoResources with symlinks.

    I have 3 contexts

    • Site A
    • Site B
    • Data

    In Data the client will add all resources with TV's to be shown across two sites.
    This way he has to edit in one place, but can show the same details across more sites.

    In context Site A and Site B he simply adds a symlink pointed to a resource in the Data context. This works great.
    (The template used for this symlink resource does not have the same TV's as the data resource so this is not a issue)

    The detail page works:
    https://c0021.paas1.lon.modxcloud.com/stay-and-eat/stay/hotels/the-d-hotel.html

    But the list view only shows the link and title no TV's...
    https://c0021.paas1.lon.modxcloud.com/stay-and-eat/stay/hotels.html

    Code:
    [[!getResources?
    &parents=`[[*id]]`
    &where=`{"template":"8"}`
    &depth=`10`
    &tvPrefix=``
    &tpl=`ListingTpl`
    &includeTVs=`1`
    &processTVs=`1`
    &prepareTVs=`1`
    ]]
    


    ListingTpl
    <div class="col-xs-12 col-sm-6 col-md-4">
    	<div class="thumbnail">
    		[[ImagePlus?
    			&docid=`[[+id]]`
    			&tvname=`ListingImage` 
    			&options=`w=520`
    			&tpl=`ListingImgTpl`  
    			&type=`tpl` 
    		]]
    		<div class="caption">
    			<h3><a href="[[~[[+id]]]]">[[+longtitle:notempty=`[[+longtitle]]`:default=`[[+pagetitle]]`]]</a></h3>
    			<address>[[+DetailsPlace]], [[+DetailsRegion]]<br>
    				<a href="tel:+[[+DetailsPhone]]">+[[+DetailsPhone]]</a><br>
    				<a href="[[+DetailsWebsite]]">[[+DetailsWebsite]]</a>
    			</address>
    			<a href="[[~[[+id]]]]" class="btn btn-primary">more</a>
    		</div>
    	</div>
    </div>
    

    This question has been answered by ThaClown. See the first response.

      MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
      DESIGNfromWITHIN, MPThemes and Any Screen Size
      Follow me on Twitter | Read my blog | My code on GitHub
    • discuss.answer
      Ok wow this works...

      //Output Modifier: [[+tv.tv-name:getSymTV=`[[+id]],tv-name`]]
       
      $options = explode(',',$options);
      $symID = $options[0];
      $tvName = $options[1];
       
      if(is_numeric($symID) && !empty($tvName)){
        $resource = $modx->getObject('modResource', $symID);
        $content = $resource->getTVValue(''.$tvName.'');
       
        if($resource->get('class_key') == 'modSymLink') {
          $linkedID = $resource->get('content');
          $linkedresource = $modx->getObject('modResource', $linkedID);
          $content = $linkedresource->getTVValue(''.$tvName.'');
        }
      }
       
      return $content;
      


      Many thanks to https://forums.modx.com/u/kctechsoln
      https://forums.modx.com/thread/78156/symlinks-getresources#dis-post-516892
        MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
        DESIGNfromWITHIN, MPThemes and Any Screen Size
        Follow me on Twitter | Read my blog | My code on GitHub