<![CDATA[ symlink_merge_fields & forward_merge_excludes - Settings question? - MODX Community Forums]]> https://forums.modx.com/thread/?thread=104244 <![CDATA[symlink_merge_fields & forward_merge_excludes - Settings question?]]> https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560680
Here's my question:

With "symlink_merge_fields" set to "yes" and "forward_merge_excludes" set to "pagetitle,longtitle" or any other MODX field. The behaviour is exactly as expected, ie. all values are taken from the Symlink within the exception of pagetitle & long title which are excluded from the Symlink & get their values from the target resource. However this does not appear to work with Template Variables, so for example with "forward_merge_excludes" set to "pagetitle,longtitle,myTV", pagetitle & longtitle are excluded but myTV still gets it's value from the Symlink.

Is this supposed to work with Template Variables? - Bob's article says, "yes" but it doesn't work for me...

https://bobsguides.com/blog.html/2017/02/28/advanced-symlinks-i/

]]>
robh76 Aug 11, 2018, 08:17 AM https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560680
<![CDATA[Re: symlink_merge_fields & forward_merge_excludes - Settings question?]]> https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560728

I assume there's some reason you can't just leave the symlink page's TV values blank and use a tag where you want to display the target page TV value:

[[*MyTv]]


Does this return the ID of the Symlink, or the Target?

return "ID: " . $this->modx->resource->get('id');


If it's the target, this should work:

return $this->modx->resource->getTVValue('MyTv');


If it's the Symlink, this should work, though it's a little tortured:

$symlink = $modx->getObject('modResource', $modx->resource->get('id'));

if ($symlink) {
   $targetId = (int) $symlink->get('content');
}

$tv = $modx->getObject('modTemplateVar', array('name' => 'MyTv'));

/* If you can use the raw value of the TV */
return $tv->getValue($targetId);

/* If not */
return $tv->renderOutput($targetId);





]]>
BobRay Aug 13, 2018, 08:13 PM https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560728
<![CDATA[Re: symlink_merge_fields & forward_merge_excludes - Settings question?]]> https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560703
Actually I've just discovered it does work with template variables. My problem was that I was trying to call the TVs via a snippet, eg..

$page = $modx->getObject('modResource', $resouceId);
$myTV=$page->getTVValue('myTV');


Of course when accessing $resourceId as a parameter it always uses the ID of the resource which contains the snippet. If it's a Document, then the Document ID. If it's a Symlink, then the Symlink ID. The symlink_merge_fields has no effect in this case.

I'm current trying to figure out a workaround for this. Is there something obvious I'm missing here?]]>
robh76 Aug 12, 2018, 09:43 AM https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560703
<![CDATA[Re: symlink_merge_fields & forward_merge_excludes - Settings question?]]> https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560690
You may also have to make sure the TVs default value is blank.]]>
BobRay Aug 11, 2018, 10:13 PM https://forums.modx.com/thread/104244/symlink-merge-fields-forward-merge-excludes---settings-question#dis-post-560690