4

In Internal Link field, Sitecore adds rootpath like "/sitecore/content" as prefix if I use the "Insert Link" button.

I would like to remove this. Is there a way to resolve this by updating .config file? or Do I have to include another config file to call process after Sitecore.Data.Fields.InternalLinkField.UpdateLink(), if it is right?

When I click the "Insert Link" button, "Insert Item" dialog pops up.

enter image description here

enter image description here

7
  • 1
    To answer the question, it would be helpful to know why you want to remove the prefix. – Sergeant Sitecore Oct 6 '16 at 19:13
  • @SergeantSitecore Suppose I have a navigation component and there are link fields like that. User navigates the target page item via "Insert Link" button and save. The link goes to like "www.google.com/sitecore/content/my/page/item" – Jihyun Oct 6 '16 at 19:24
  • 2
    Sounds like you're not generating your final link correctly. Either you're not using LinkManager to generate the URL on your rendering, or possibly you're referencing a content Item that isn't under the root item of your Site definition, which can confuse the LinkManager. Can you provide the specific details that relate to my assumptions here so that I can provide a detailed, correct answer to your problem? I need to see your navigation objects in the tree, your site definition (XML) and the objects you're trying to link to in the tree. – Sergeant Sitecore Oct 6 '16 at 19:29
  • Basically, I'm using LinkManager(?) to generate URL and the content item is under root item of my site, like under "/home/". I updated a screenshot which is dialog popup when I click "Insert Link" button. I think you are talking about LinkManager as "Insert Link" dialog popup. Now, it says "Insert Item" if I use "Internal Link" data type. – Jihyun Oct 6 '16 at 19:38
  • When you say "under /home/" do you mean a child of /Home or a sibling? It must be a child for this to work how you want it too. From your screen shot, it looks like it could be a child. Hard to tell with the black box there – Richard Seal Oct 6 '16 at 19:41
3

Internal Link is a System field type. Unless you're creating new Sitecore features, I'd recommend you switch to one of the following:

*Generallink Use this if your users can select both Sitecore Items and external URLs.

*Droplink Use this if you want to force the user to select a Sitecore Item.

These field types can be found under the "Linking" group when you define the Field on the Data Template.

3
  • What is the "Internal Link" data type for? There are some other available link types and I can change to "General Link", "Drop" or "Media Link and External Link". All of these includes "Internal Link" as well. Does "Internal Link" restrict external link url?? That's why?? – Jihyun Oct 6 '16 at 19:47
  • Anything in the System group is used by Sitecore for its own nefarious devices and should not be used by developers building websites. I'm sure someone smarter than me knows the official answer. I can tell you that the internallink field is very old. – Sergeant Sitecore Oct 6 '16 at 19:49
  • I think you are right because "Insert Link" field is in System group. Thanks! – Jihyun Oct 6 '16 at 20:04
1

Before you start remember that value you see in this field is the actual value of the field (this is true raw value of the field).

You will have to modify then two things:

  • value of the field while saving
  • logic for resolving the field value (getting item)

How to:

You need to create your own custom InternalLink

InternalLink.cs

using Sitecore.Data.Items;

namespace Sitecore.Custom.CustomFields.FieldTypes
{
    public class InternalLink : Shell.Applications.ContentEditor.InternalLink
    {
    }
}

Configuration

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <controlSources>
            <source patch:before="*[@namespace='Sitecore.Shell.Applications.ContentEditor']" mode="on" namespace="Sitecore.Custom.CustomFields.FieldTypes" assembly="Sitecore.Custom" prefix="content"/>
        </controlSources>
    </sitecore>
</configuration>

You will need new implementation of:

protected void OpenLink(ClientPipelineArgs args)

method to handle your custom link format.

1
  • hmmm... there are more things than I expected.. – Jihyun Oct 6 '16 at 18:22
0

I don't really suggest to implement a custom field to change this because it is too painful. I think you should change the logic where this field is used and resolve there correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.