12

I am trying to get Tridion to gracefully handle things when its connection to our External Content Library is down. I am able to get a notification to popup by throwing an exception. However, I also want to show the service is down in the Content Management tree.

I have this working to the point where it shows a message, but there are some issues with the way we are doing this. We add another node to the tree that displays the error message, but we add it as a file. This file is able to be expanded upon as if it were a folder.

The image below shows how I currently have it working. It displays the error message I want; however, it still allows the item to be clicked as if it were a folder. I currently have that node set as a file.

enter image description here

The image below illustrates what I want to get rid of: the ability for the user to expand into this error that we've added.

enter image description here

Any information to fix these issues would be tremendously helpful. Thank you.

1
  • I am not sure what is wrong here. In general when you can expand a node from an extension (and ecl is in itself an extension) and get the standard Tridion root items as child items, it is a sign an extension (so ecl) did not correctly intercept the messages send from the UI to the tridion core... How does the URL of your item look? Sep 17, 2013 at 17:26

1 Answer 1

9

The icon on the mountpoint is set in the IconIdentifier method in the class that implements the IContentLibraryContext interface. For instance you could have something in there like:

public string IconIdentifier
{
    get {
        if (_disconnected) return "disconnected";
        return "connected"; 
    }
}

The value for _disconnected you have to set somewhere based on whether your connection is up.

Then to make icons available from a simple to deploy location, I add a few additional methods to the class that implements the IContentLibrary interface (allowing me to add the icons in the AddIns folder where the ECL provider DLL resides). These are called from the GetIconImage method that needs to be implemented by the interface:

private static readonly string IconBasePath = Path.Combine(AddInFolder, "Themes");'

internal static string AddInFolder
{
    get
    {
        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
        UriBuilder uri = new UriBuilder(codeBase);
        string path = Uri.UnescapeDataString(uri.Path);
        return Path.GetDirectoryName(path);
    }
}

internal static byte[] GetIconImage(string iconIdentifier, int iconSize)
{
    int actualSize;
    // get icon directly from default theme folder
    return HostServices.GetIcon(IconBasePath, "_Default", iconIdentifier, iconSize, out actualSize);
}

public byte[] GetIconImage(string theme, string iconIdentifier, int iconSize)
{
    // use static implementation
    return GetIconImage(iconIdentifier, iconSize);
}

So with this code, I can now add a Themes\_Default\Icons folder to the AddIns folder and in there place the following icons:

disconnected.16x16.png
disconnected.24x24.png
disconnected.32x32.png
disconnected.48x48.png
connected.16x16.png
connected.24x24.png
connected.32x32.png
connected.48x48.png

You can see a sample of using custom icons like that in my Flickr ECL provider which is open source code (available on Google code).

Then your next step would be to have the GetItem and GetFolderContent methods in the class that implements the IContentLibraryContext interface to not return items (and folders) anymore, that way you would not have an option to further expand.

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.