How to add external systems redirection with Xperience core?

Liya Han asked on December 17, 2021 08:49

We'd like to add some external systems url on Xperience core site and set them as menu items. How can I set their links after I created the tree node on admin interface? Please see below example.

Node1

Node11

Chrome - Need jump to chrome site when click this menu item.

Thank you in advance!

Correct Answer

Brenden Kehren answered on December 21, 2021 16:58

The easiest way to achieve this is to:

  1. Create a page type called External Link
  2. Add a few fields to it for Name, DisplayText, LinkURL
  3. In your Repo for navigation make sure you use pageRetriever.RetrieveMultiple() like so.

var items = pageRetriever.RetrieveMultiple( query => query .Path(path, PathTypeEnum.Section) .InCategories(categoryName) .WithCoupledColumns() .OrderBy(nameof(TreeNode.NodeLevel), nameof(TreeNode.NodeOrder)), cache => cache .Key($"{nameof(NavigationRepo)}|{path}|{categoryName}|{nestingLevel}") .Dependencies((_, builder) => builder.PagePath(path, PathTypeEnum.Children).ObjectType(TreeNode.OBJECT_TYPE).PageOrder()));

  1. When you create your DTO object from the retrieved objects add a logical statement to set the link text and URL like so.

List<NavigationItem> navItems = items.Select(node => new NavigationItem { LinkText = node.ClassName == CMS.DocumentEngine.Types.Company.ExternalLink.CLASS_NAME ? node.GetStringValue(nameof(CMS.DocumentEngine.Types.Company.ExternalLink.RedirectUrlText), "") : node.DocumentName, LinkUrl = node.ClassName == CMS.DocumentEngine.Types.Company.ExternalLink.CLASS_NAME ? node.GetStringValue(nameof(CMS.DocumentEngine.Types.Company.ExternalLink.RedirectURL), "") : pageUrlRetriever.Retrieve(node).RelativePath }).ToList();

This should get you what you're looking for.

0 votesVote for this answer Unmark Correct answer

Recent Answers


vasu yerramsetti answered on December 19, 2021 09:06 (last edited on December 19, 2021 09:07)

Current we don't have any out-of-the-box option for this requirement but you can go with custom page type Or custom field of existing page type for store external links an.d implement logic accordingly on your core project.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.