3

We have created an item resolver to maintain Sitecore path on our way. We have inherited LinkProvider to override GetItemUrl method like the below:

public class LinkProvider : Sitecore.Links.LinkProvider
    {
        public override string GetItemUrl(Item item, UrlOptions options)
        {
           //Some Code Implementation

            return base.GetItemUrl(item, options);
        }
    }

We have added our own config file with name custom_config.config in include folder but we are unable to use our own override method. I checked showconfig.aspx also, but this is showing me the OOTB LinkProvider type Sitecore.Providers.LinkProvider instead of the one which we have created.

  • 2
    Can you post your patch file for your link provider – Chris Auer Dec 16 '16 at 4:08
  • I have added the patch file but now I have created custom folder and added that patch file there. It seems to be working. Thanks both. – Akaa Dec 16 '16 at 4:29
4

Please verify that your patch file is patching correctly. Since you do not see it in your showconfig.aspx, most likely your patch file is not configured correctly.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <linkManager>
      <providers>
        <add name="sitecore">
          <patch:attribute name="type">Sitemap.Custom.CustomLinkProvider,Sitemap.Custom</patch:attribute>
        </add>
      </providers>
    </linkManager>
  </sitecore>
</configuration>
| improve this answer | |
2

Also to note that Sitecore first processes include files directly inside the App_Config/Includes folder in alphabetical order (technically, the order returned by the Directory.GetFiles() method) and then process folders inside App_Config/Includes folder in alphabetical order and files inside those folders.

If you need to use a include file(i.e. custom_config.config) to override something in another include file(i.e. sitecore.config), the name of the overriding file should sort after the name of the overridden file. So rename custom_config.config to appear after sitecore.config to resolve the same. You can use something like z_custom_config.config so that it will appear after sitecore.config.

We usually create our own folder to contain custom config files as recommended practice. This is to ensure that your custom config file is always included.

| improve this answer | |

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.