Tuesday, July 17, 2007

MDM Multiple Languages

MDM has great support for multiple languages. You can login to their GUI client (Data Manager) with your desired language. I found out that when you use the MDM COM API with multiple languages to get images you have to use their enumerations.

You can’t pass in “Original”, you must pass in XCATCOMLib.ImageVariantTypeEnum.xcOriginalType
I also had to get the “Images” tableID. Otherwise the Secondary languages will not retrieve an image.

Here’s a function to get an image:

public static string GetImage(XCATCOMLib.Fields objFields, XCATCOMLib.Catalog catalog, ImageVariantTypeEnum variantType)
string imgURL;
System.Object[] imgID = (System.Object[])objFields.Item(”Images”).Value;
int imagesTable = objFields.Item(”Images”).LookupTableID;
int webimgID = int.Parse(imgID.GetValue(0).ToString());

CachedImageInfo imgInfo = catalog.GetCachedImageInfo(imagesTable, webimgID, variantType);
string imageCached = imgInfo.CachedPath.Replace(”\\”,”/”);
imgURL = ConfigurationSettings.AppSettings[”ImagesCacheFolder”] + “/” + imageCached;

return imgURL;