0

I am dynamically constructing the left menu for the product

View:

            @foreach (var item in Model.Children)
       {
         <div class="btn btn-default">

        <a id="[email protected]"  href="@Sitecore.Links.LinkManager.GetItemUrl(@item)"><span class="@item["Icon"]"></span><span class="nameText">@item["Title"]</span></a>


              </div>
         }

when clicking the link am getting url as QAV1/sitecore/Content/Property/Ridgepoint/Photos?sc_lang=en

how to avoid sitecore/content/ in the url?

Site Definition:

           <site name="qav1" patch:before="site[@name='website']"
         virtualFolder="/"
        physicalFolder="/"
        rootPath="/sitecore/content/Property/"
        startItem="/Home"
        database="web"
        domain="extranet"
        allowDebug="false"
        cacheHtml="true"
        htmlCacheSize="50MB"
        enablePreview="true"
        enableWebEdit="true"
        enableDebugger="true"
        useDisplayName="true"

        disableClientData="false"/>
</sites>
7
  • What's the configuration for the site in question? my guess is that the site definition is not correct. Also what is the full URL that gets rendered, is it just "qav1/sitecore/content/Product/MenuName" Commented May 1, 2018 at 15:54
  • Full URL:QAV1/sitecore/Content/Property/Ridgepoint/Photos?sc_lang=en
    – sindu
    Commented May 1, 2018 at 16:02
  • added site definition
    – sindu
    Commented May 1, 2018 at 16:03
  • Can you also add here definition of your linkmanager? Something like this - <linkManager defaultProvider="sitecore"> <providers> <clear /> <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="false" alwaysIncludeServerUrl="true" encodeNames="true" languageEmbedding="never" languageLocation="filePath" shortenUrls="true" useDisplayName="false" /> </providers> </linkManager> Commented May 2, 2018 at 8:52
  • 1
    Another thing I just realized that you have startItem set as "/Home". Do you have item like that in your tree? If no, then remove "Home" and make it just "/". Links are always generated relatively to startItem and if it doesn't exist, I believe you end with full path which is your case... Commented May 2, 2018 at 9:11

1 Answer 1

1

The reason you're getting the full path is because your Site definition points to:

/sitecore/content/Property/

But the item you're rendering a url for is:

qav1/sitecore/content/Product/MenuName

This means, it's not under the Property item which is the starting point of the site. So, for the url to work (i.e. Sitecore to be able to find the item based on the url) it needs the full item path (as it wouldn't find it under Property). So the MenuName or the Product item needs to be under Property, in that case it will render the url without gav1/sitecore/content.

2
  • my url is QAV1/sitecore/Content/Property/Ridgepoint/Photos?sc_lang=en added in the previous comment
    – sindu
    Commented May 1, 2018 at 16:22
  • Your rootpath is pointing to /sitecore/content/Property, so there's no URL possible to render without the full path for the Product since it lives in /sitecore/content/Property Commented May 1, 2018 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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