1

When I try to add folders and files in the same folder, all the elements that I'm adding are showed as folders.

My DisplayTypes:

    public IList<IDisplayType> DisplayTypes
    {
        get
        {
            return new List<IDisplayType>
            {
                HostServices.CreateDisplayType("bccf", "Countries", EclItemTypes.Folder),
                HostServices.CreateDisplayType("bctf", "Cities", EclItemTypes.Folder),
                HostServices.CreateDisplayType("bchf", "Hotels", EclItemTypes.Folder),
                HostServices.CreateDisplayType("bcci", "BrandCenter Country Image", EclItemTypes.File),
                HostServices.CreateDisplayType("bcti", "BrandCenter City Image", EclItemTypes.File),
                HostServices.CreateDisplayType("bchi", "BrandCenter Hotel Image", EclItemTypes.File)
            };
        }
    }

My MountPoint/GetFolderContent:

    public IFolderContent GetFolderContent(IEclUri parentFolderUri, int pageIndex, EclItemTypes itemTypes)
    {
        var items = new List<IContentLibraryListItem>();
        var itemsImg = new List<IContentLibraryMultimediaItem>();
        if (parentFolderUri.ItemType == EclItemTypes.MountPoint && itemTypes.HasFlag(EclItemTypes.Folder))
        {
            requestCountries req = new requestCountries();
            req.initial = 0;
            req.number = 100;
            CountriesList cs = BrandCenterProvider.ClientCountriesList.getCountries(req);
            foreach(Country country in cs.countries){
                FolderBC f = new FolderBC(country);
                BrandCenterFolder h = new BrandCenterFolder(parentFolderUri.PublicationId, f);
                items.Add(h);
            }
        }

        if (parentFolderUri.ItemType == EclItemTypes.Folder)// && itemTypes.HasFlag(EclItemTypes.File))
        {
            if (parentFolderUri.SubType == "bccf")
            {
                requestCities req = new requestCities();
                req.paiId = int.Parse(parentFolderUri.ItemId);
                req.initial = 0;
                req.number = 100; 
                CitiesList cs = BrandCenterProvider.ClientCitiesList.getCities(req);
                foreach(City city in cs.cities){
                    FolderBC f = new FolderBC(city);
                    BrandCenterFolder h = new BrandCenterFolder(parentFolderUri.PublicationId, f);
                    items.Add(h);
                }

                requestImageCountries req2 = new requestImageCountries();
                req2.initial = 0;
                req2.number = 100;
                req2.paiId = int.Parse(parentFolderUri.ItemId);
                ImageCountriesList cs2 = BrandCenterProvider.ClientImagesCountries.getImageCountries(req2);
                foreach (ImageCountry c in cs2.countries)
                {
                    ImageBC i = new ImageBC(c);
                    BrandCenterImage image = new BrandCenterImage(parentFolderUri.PublicationId, i);
                    itemsImg.Add(image);

                    foreach (Indra.Tridion.ECL.BrandCenter.BrandCenter.Service.Client.CountryImages.Version v in c.versions)
                    {
                        ImageBC iv = new ImageBC(v, c.name, c.creation_date);
                        BrandCenterImage imageVersion = new BrandCenterImage(parentFolderUri.PublicationId, i);
                        itemsImg.Add(imageVersion);
                    }
                }
            }
            if (parentFolderUri.SubType == "bctf")
            {
                requestHotels req = new requestHotels();
                req.initial = 0;
                req.number = 100;
                req.ciuId = int.Parse(parentFolderUri.ItemId);
                HotelsList cs = BrandCenterProvider.ClientHotelsList.getHotels(req);
                foreach (Hotel c in cs.hotels)
                {
                    FolderBC f = new FolderBC(c);
                    BrandCenterFolder h = new BrandCenterFolder(parentFolderUri.PublicationId, f);
                    items.Add(h);
                }

                requestImageCities req2 = new requestImageCities();
                req2.initial = 0;
                req2.number = 100;
                req2.ciuId = int.Parse(parentFolderUri.ItemId);
                ImageCitiesList cs2 = BrandCenterProvider.ClientImagesCities.getImageCities(req2);
                foreach (ImageCity c in cs2.cities)
                {
                    ImageBC i = new ImageBC(c);
                    BrandCenterImage image = new BrandCenterImage(parentFolderUri.PublicationId, i);
                    itemsImg.Add(image);
                    BrandCenterProvider.hotels.Add(image.Id.ToString(), image);

                    foreach (Indra.Tridion.ECL.BrandCenter.BrandCenter.Service.Client.CityImages.Version v in c.versions)
                    {
                        ImageBC iv = new ImageBC(v, c.name, c.creation_date);
                        BrandCenterImage imageVersion = new BrandCenterImage(parentFolderUri.PublicationId, i);
                        itemsImg.Add(imageVersion);
                    }
                }
            }
            if (parentFolderUri.SubType == "bchf")
            {

                requestImageHotels req = new requestImageHotels();
                req.initial = 0;
                req.number = 10;
                req.hotId = int.Parse(parentFolderUri.ItemId);
                ImageHotelsList cs = BrandCenterProvider.ClientImagesHotels.getImageHotels(req);
                foreach (ImageHot c in cs.hotels)
                {
                    ImageBC i = new ImageBC(c);
                    BrandCenterImage image = new BrandCenterImage(parentFolderUri.PublicationId, i);
                    itemsImg.Add(image);

                    foreach (Indra.Tridion.ECL.BrandCenter.BrandCenter.Service.Client.HotelImages.Version v in c.versions) {
                        ImageBC iv = new ImageBC(v, c.name, c.creation_date);
                        BrandCenterImage imageVersion = new BrandCenterImage(parentFolderUri.PublicationId, i);
                        itemsImg.Add(imageVersion);
                    }
                }
            }
        }

        items.AddRange(itemsImg);
        return BrandCenterProvider.HostServices.CreateFolderContent(parentFolderUri, items,
            false, CanSearch(parentFolderUri.PublicationId));
    }

Summarizing, When the GetFolderContent method starts is creating two lists:

    var items = new List<IContentLibraryListItem>();
    var itemsImg = new List<IContentLibraryMultimediaItem>();

During the process I add files or folders in every list.

When the method finish I merge both lists:

    items.AddRange(itemsImg);
    return BrandCenterProvider.HostServices.CreateFolderContent(parentFolderUri, items,
        false, CanSearch(parentFolderUri.PublicationId));

Then, In the GUI, is showing all the items as folders.

Definition of BrandCenterFolder:

public class BrandCenterFolder : ListItem, IContentLibraryItem
{
    public BrandCenterFolder(int publicationId, FolderBC info)
        : base(publicationId, info)
    {
        // if info needs to be fully loaded, do so here
    } ....

Definition of BrandCenterImage:

class BrandCenterImage : ListItem, IContentLibraryMultimediaItem
{
    public BrandCenterImage(int publicationId, ImageBC i)
        : base(publicationId, i) {}

    public IContentLibraryItem Save(bool readback)
    {
        return readback ? this : null;
    }  ....

My ListItem Class:

public class ListItem : IContentLibraryListItem { internal readonly FolderBC InfoFolder; internal readonly ImageBC InfoImage;

    private readonly IEclUri _id;

    public ListItem() { 
    }

    public ListItem(int publicationId, FolderBC info)
    {
        InfoFolder = info;
            _id = BrandCenterProvider.HostServices.CreateEclUri(publicationId, BrandCenterProvider.MountPointId, InfoFolder.id, DisplayTypeId, EclItemTypes.Folder);
    }

    public ListItem(int publicationId, ImageBC info)
    {
        InfoImage = info;
        _id = BrandCenterProvider.HostServices.CreateEclUri(publicationId, BrandCenterProvider.MountPointId, InfoImage.id, DisplayTypeId, EclItemTypes.File);
    }

Why is not showing the BrandCenterImage objects as files?

In the execution of the GetContentFolder method, when I arrive to the last folder of the tree, GetContentFolder is returning only BrandCenterImages. In this case, It's working fine and is showing this elements as files.

4

If you mean the files show up in the tree view on the left, it is because you are ignoring the itemTypes parameter in GetFolderContent.

Only return files if itemTypes.HasFlag(EclItemTypes.File)) is true. And similarly, only return folders if itemTypes.HasFlag(EclItemTypes.Folder)) is true. If they are both true, return both folders and files.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.