<![CDATA[ changing the alias for symlink resources - My Forums]]> https://forums.modx.com/thread/?thread=104420 <![CDATA[changing the alias for symlink resources]]> https://forums.modx.com/thread/104420/changing-the-alias-for-symlink-resources#dis-post-561634
Is there a way to change the (alias variable) for symlinks resources?

I mean, i created 1 resource(lest call it master), fillrd in the content with text, and then created like 5 copys(symlinks) everywhere in my site(please, forget about SEO implications for having duplicates, i resolved that qith 1 index,follo XD ).

But now i want to change the alias for my "master" resource, but i realized i have to change the alias for those symlinks too?

i believed that changing the alias in the master would replicate to all the symlinks, but sadly, they dont change sad

do i have to change it manually?

Thanks]]>
jacielluve Sep 19, 2018, 02:44 PM https://forums.modx.com/thread/104420/changing-the-alias-for-symlink-resources#dis-post-561634
<![CDATA[Re: changing the alias for symlink resources]]> https://forums.modx.com/thread/104420/changing-the-alias-for-symlink-resources#dis-post-561657 Quote from: BobRay at Sep 19, 2018, 05:24 PM
I'm afraid so. MODX doesn't maintain an internal link from a master to its Symlinks.

Thanks Bob, that would be a nice modx feature(at least for me, right now) ill have to change it manually now sad

i will use the utility provided, for another purposes smiley

Thanks]]>
jacielluve Sep 19, 2018, 07:00 PM https://forums.modx.com/thread/104420/changing-the-alias-for-symlink-resources#dis-post-561657
<![CDATA[Re: changing the alias for symlink resources (Best Answer)]]> https://forums.modx.com/thread/104420/changing-the-alias-for-symlink-resources#dis-post-561648
You could do it with a utility snippet like this (untested):

Put this tag in a resource:

[[FixSymlinks]]



Then create a snippet called FixSymlinks with this code:

/* FixSymlinks snippet */
$masterId = 12; // replace 12 with the ID of the master
$master = $modx->getObject('modResource', $masterId);
$alias = $master->get('alias');
$sls = $modx->getCollection('modResource', array('content' => $masterId));

if (empty($sls)) {
   return "<p>No Symlinks found</p>";
}

$count = 0;
foreach($sls as $symlink) {
   $symlink->set('alias', $alias);
   if ($symlink->save()) {
      $count++;
   }
}

return "<p>" . $count . " Symlinks fixed</p>";


Then view the resource with the tag.

You can use it on multiple masters by changing the $masterId.]]>
BobRay Sep 19, 2018, 05:24 PM https://forums.modx.com/thread/104420/changing-the-alias-for-symlink-resources#dis-post-561648