Try our conversational search powered by Generative AI!

Non-internal API for Shortcuts

Vote:
 

Recently I had to write a migration that moved a few pages and create shortcuts to their new location from the old location. Creating a shortcut from code seemed like a common enough use case but at every turn I was twarted by the fact that every API support was internal and not accessible. In the end I had to resort to direct manipulation of the property collection.

Workaround, if anyone else needs it:

        private void CreateShortCut(ContentReference parentReference, PageData original) where T : PageData
        {
            var shortcut = _contentRepository.GetDefault(parentReference, original.Language);
            shortcut.Name = original.Name;
            shortcut.URLSegment = original.URLSegment;
            shortcut.LinkType = PageShortcutType.Shortcut;
            shortcut[MetaDataProperties.PageShortcutLink] = original.PageLink;
            _contentRepository.Save(shortcut, SaveAction.Publish, AccessLevel.NoAccess);
        }
#188312
Feb 19, 2018 15:22
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.