Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello guys ,
I'm so younger user of Umbraco Cms .
I would be glad if some of you help me to solve my problem .
I have Json file , it includes all information about my content tree. After upload the file to Web API , application create content tree programmatically.
Problems begin later:
After creating any node , I would like to set the culture and hostnames programmatically .
If some of you hit on with this case , please ask me to set it.
Thank you very much ,
enter image description here
You can set the Domain and Hostname using the DomainService
the main thing you need to do once you have a reference to the service, is to create a UmbracoDomain object and then set the domain, languageId and the Id to the content you want it to apply to (e.g your site homepage).
you need to get the language Id from the LocalizationService (see bottom)
// assuming you have worked out the languageId and
// contentNode is the node you want to set this on.
var domain = new UmbracoDomain(domainName);
domain.LanguageId = languageId;
domain.RootContentId = contentNode.Id;
the languageId is the Id of the installed language on umbraco (so as they appear in the Developer/Languages - normally this will just be the order they are in (so top one is 1) but if you have added & removed languages that might not be true - so to be certain use the LocalizationServices
you can do this by culture code or Iso Language Code
// by name
var lang = _localizationService.GetLanguageByCultureCode(fName.Value);
// by iso code
var lang = _localizationService.GetLanguageByIsoCode(culture.Value);
with this you can get the id lang.Id for the first snippet of code.
Oh thank you , bro!
Look at this :
var contentService = ApplicationContext.Current.Services.ContentService;
var publishDate = DateTime.Now;
var content = contentService.CreateContent(name, parentPageId, docTypeAlias);
content.ReleaseDate = publishDate;
content.CreateDate = publishDate;
content.UpdateDate = publishDate;
var result =contentService .SaveAndPublishWithStatus(content);
Can you impove this method with you top description? Add set of culture.
Hi I would have a sperate thing for the domain language, you only need set it on at one level and all the content pages below will inherit it.
I have to ask different culture for different nodes.
Yeah unless every node is different you will probably only need to set the domain and language a few times, at the highest level for each part of the content tree.
i am not sure but i think setting the domain and language on every single node will result in quite a lot of extra data and config being stored and might impact on the performance of your site.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted