2013-10-30 24 views

回答

1

也许这样的事情会对你有帮助吗?

var domain = new umbraco.cms.businesslogic.web.Domain("example.com") 
       { 
        RootNodeId = 1078, 
        Language = Language.GetByCultureCode("en-GB"), 
       }; 
domain.Save(); 
+1

十亿感谢@ProNotion。你的代码指出我正确的方向! 我发现这种方法: 'umbraco.cms.businesslogic.web.Domain.MakeNew(name,content.Id,umbraco.cms.businesslogic.language.Language.GetByCultureCode(“en-US”)。id);' –

1

为一把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); 
相关问题