Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nicholas Westby 2054 posts 7100 karma points c-trib
    Jun 02, 2016 @ 19:51
    Nicholas Westby
    1

    Programmatically Get/Set Document Type Icon Color

    I noticed I can get/set an icon for a document type on IContentType.Icon, but I haven't seen how to get the icon color yet. The color being specified in this interface:

    Icon

    Here's an example of the code to get an icon:

    // I can get an icon, but not sure how to get the icon color.
    var icon = ApplicationContext.Services.ContentTypeService.GetAllContentTypes().First().Icon;
    

    I have already confirmed that the icon color is not a class stored in the Icon property.

  • Tobias Lopez 64 posts 210 karma points
    Oct 18, 2018 @ 15:24
    Tobias Lopez
    0

    Have you found a way to set it programmatically?

  • Anders Bjerner 487 posts 2989 karma points MVP 8x admin c-trib
    Oct 18, 2018 @ 15:53
    Anders Bjerner
    0

    In your example, what does the Icon property return? It actually should contain both the class name for the icon it self and the class name for the color. Although, as black is the default color, it's not included in the value if the selected color is black.

    So for instance, if you have selected the house icon and chosen a black color, the saved value will be icon-home.

    If you instead choose blue as the color, the saved value will be icon-home color-blue.

    You can see the supported colors here:

    https://github.com/umbraco/Umbraco-CMS/blob/2bb5d0b30eee2f4016b8b48034cb7ec717da66a9/src/Umbraco.Web.UI.Client/src/views/common/overlays/iconpicker/iconpicker.controller.js#L14

    Hope that helps ;)

Please Sign in or register to post replies

Write your reply to:

Draft