Dynamic Content: Multilingual item default url not populating
Hi,
My project has multilingual support for all the countries like, en-US, es-US, en-CA, fr-CA.
I created custom module using module builder having 1-parent and 3-child content type for it for to hold some static information for different countries.
So, i am getting the contents from rest service and adding into module through programmatically. Which is works fine. I can able to browse all the contents in backend. I just browsed the content has both (en-US,en-CA) versions so, i browsed sub content type of both country. one country is working(en-US) not the other (en-CA)
After i debug and found that 'sf_dynamic_content' which has item_default_url for all the languages.
it is updating only for default language (en-US) not others.
So, I did another thing. Instead of adding the content through programattically added manually backend. which is working fine for all the countries.
Please help me on this? how to resolve.....
Here is my code for inserting content
DynamicContent productInfoItem = manager.GetDataItems(contentType).Where(a=>a.GetValue<string>("Title").Equals(data.Title)).FirstOrDefault();
if (productInfoItem == null)
productInfoItem = manager.CreateDataItem(contentType);
// This is how values for the properties are set.
productInfoItem.SetString("Title", data.Title, culture);
productInfoItem.SetString("Name", data.Name, culture);
productInfoItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
productInfoItem.SetValue("PublicationDate", DateTime.Now.ToUniversalTime());
productInfoItem.SetString("UrlName", new Lstring(Regex.Replace(data.Title.ToLower(), UrlNameCharsToReplace, UrlNameReplaceString)),culture);
// Publishing the product info item
manager.RecompileDataItemsUrls(contentType);
productInfoItem.ApprovalWorkflowState.SetString(culture, "Published");
manager.Lifecycle.Publish(productInfoItem,culture);
manager.SaveChanges();
I got a fix for this issue
set the culture before do a publish the content through code Thread.CurrentThread.CurrentUICulture = culture;
Works fine now.
public DynamicContent createNewProductInfo(ProductInfoModel data,Type contentType,CultureInfo culture, DynamicModuleManager manager)
Thread.CurrentThread.CurrentUICulture = culture;
DynamicContent productInfoItem = manager.GetDataItems(contentType).Where(a=>a.GetValue<string>("Title").Equals(data.Title)).FirstOrDefault();
if (productInfoItem == null)
productInfoItem = manager.CreateDataItem(contentType);
// This is how values for the properties are set.
productInfoItem.SetString("Title", data.Title, culture);
productInfoItem.SetString("Name", data.Name, culture);
productInfoItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
productInfoItem.SetValue("PublicationDate", DateTime.Now.ToUniversalTime());
productInfoItem.SetString("UrlName", new Lstring(Regex.Replace(data.Title.ToLower(), UrlNameCharsToReplace, UrlNameReplaceString)),culture);
// Publishing the product info item
manager.RecompileDataItemsUrls(contentType);
productInfoItem.ApprovalWorkflowState.SetString(culture, "Published");
manager.Lifecycle.Publish(productInfoItem,culture);
manager.SaveChanges();
Thanks,
P.S Got the fix from Hardy in google+ sitefinitydev community