Umbraco IContent オブジェクトのホスト名をプログラムで管理する方法を知っている人はいますか?
サイト全体を csv からインポートする必要があり、ホスト名をコードから自動的に設定する必要があります。
ありがとう !
Umbraco 6+ API バージョンの場合、これはある程度役立つかもしれません - これは既存のコードから適応されています - しかし、要点を理解する必要があります:
private readonly IDomainService _umbDomainService;
private readonly ILocalizationService _umbLocalizationService;
...
this._umbDomainService = ApplicationContext.Current.Services.DomainService;
this._umbLocalizationService = ApplicationContext.Current.Services.LocalizationService;
...
//Ensure the language:
var language = this._umbLocalizationService.GetLanguageByIsoCode(config.CultureInfo.Name);
if (language == null)
{
language = new Language("en-GB");
language.CultureName = "English UK, not sure used...";
this._umbLocalizationService.Save(language);
}
//TODO: Set the main language on the node...?
this._umbContentService.Save(rootTarget); //The root node using the domain
//Set the domain:
IDomain domain = new UmbracoDomain("www.example.com");
domain.LanguageId = language.Id;
domain.RootContentId = rootTarget.Id; //id of root node to apply domain to
_umbDomainService.Save(domain);
おそらく、このようなものがあなたを助けるでしょうか?
var domain = new umbraco.cms.businesslogic.web.Domain("example.com")
{
RootNodeId = 1078,
Language = Language.GetByCultureCode("en-GB"),
};
domain.Save();