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="lnk-@item.DisplayName"  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>
  • 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" – Jarmo Jarvi May 1 '18 at 15:54
  • Full URL:QAV1/sitecore/Content/Property/Ridgepoint/Photos?sc_lang=en – sindu May 1 '18 at 16:02
  • added site definition – sindu May 1 '18 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> – Peter Procházka May 2 '18 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... – Peter Procházka May 2 '18 at 9:11
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.

  • my url is QAV1/sitecore/Content/Property/Ridgepoint/Photos?sc_lang=en added in the previous comment – sindu May 1 '18 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 – Jarmo Jarvi May 1 '18 at 16:44

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.