I have a problem displaying SitecoreInfoType.Url in a sitecore multihomed solution.
On my sitecore 2 sites:
Site A contains some articles:
- www.Site-A / Articles / Article 1
- www.Site-A / Articles / Article 2
On our main “article landing page” we have a widget that shows a brief description of each article with links to the article page.
to use url, we map it to SitecoreInfoType.Url
eg.
[SitecoreInfo(SitecoreInfoType.Url)]
public virtual string Url { get; set; }
This displays correctly, as it is used on site A, we get dynamic URLs, for example / ru / Articles / {Article Name}.
If we try to use the widget on site B, the URL will not be created as expected:
- / ru / sitecore / content / Site A / Home / Articles / {Article title}
Sitecore Link, UrlOptions .
.
[SitecoreField(UrlOptions = SitecoreInfoUrlOptions.SiteResolving)]
public virtual Link AlternateLink { get; set; }
. , , URL-.
- A.
- B, B
- URL : www.Site-A/Articles/{Target item}
, , SitecoreField SitecoreInfoType.Url.
:
[SitecoreInfo(SitecoreInfoType.Url, UrlOptions = SitecoreInfoUrlOptions.SiteResolving)]
public virtual string Url { get; set; }
:
- A.
- B, B
- URL :/ru/sitecore/content/ A///{ }
:
- UrlOptions, SitecoreInfoType.Url, :
SitecoreInfoUrlOptions.AddAspxExtension
SitecoreInfoUrlOptions.AlwaysIncludeServerUrl
SitecoreInfoUrlOptions.LanguageEmbeddingNever
SitecoreInfoUrlOptions.AlwaysIncludeServerUrl : www.Site B/en/sitecore/content/ A///{ }
, .
- ?
API Sitecore LinkManager, .
:
<sites>
<site name="siteA"
patch:before="site[@name='website']"
hostName="siteA.domain.com"
targetHostName="siteA.domain.com"
virtualFolder="/"
physicalFolder="/"
rootPath="/sitecore/content/domain/siteA"
startItem="/Home"
database="web"
domain="extranet"
allowDebug="true"
cacheHtml="true"
htmlCacheSize="50MB"
enablePreview="true"
enableWebEdit="true"
enableDebugger="true"
disableClientData="false"
scheme="http"
/>
<site name="siteB"
patch:before="site[@name='website']"
hostName="siteB.domain.com"
targetHostName="siteB.domain.com"
virtualFolder="/"
physicalFolder="/"
rootPath="/sitecore/content/domain/siteB"
startItem="/Home"
database="web"
domain="extranet"
allowDebug="true"
cacheHtml="true"
htmlCacheSize="50MB"
enablePreview="true"
enableWebEdit="true"
enableDebugger="true"
disableClientData="false"
scheme="http"
/>
</sites>