Using iTop

Creating your iTop

iTop Customization

"How to" examples

User Interface

Automation & Ticket management

Portal Customization

:: Version 3.2.0 ::

Icon and color on a class

Prerequisite: You must be familiar with the Syntax used in Tutorials and have already created an extension.

Define an icon and an color for a class
XML, Attribute, Enum, Color, Icon
min version:

The iTop 3.0 brings new capabilities to highlight information when displaying an object alone.

  • A specific color on each class, (also used on list) as a colored line, to differentiate more easily classes.
  • Value of an Enumeration field is displayed under the object name, with color associated to the value (eg. Ticket Status)
  • A instance specific icon can even be used, so the image is different on each object (eg. Person)

With ITSM Designer

Navigate to the class definition, and pick and choose the color and attributes you want to use:

Result in iTop

With an Extension

In order to take advantage of this new capability on classes which you have define yourself, acquired through an extension or which are built-in iTop, we will detail the XML changes to do for defining or changing those colors, within an XML extension

Class icon

Within the datamodel.xxxx.xml file, add a style tag to the class properties

itop-design / classes
  <class id="FAQCategory" _delta="if_exists">
        <!--Specify an optional icon for your class (relative path from iTop module)-->
        <icon _delta="define">../my-extension-code/images/icon8-faq.svg</icon>

Constrains for the icon:

  • We recommend svg format as it is smaller and is nicer when zoomed.
  • The icon must be square
  • 240px sounds like a ideal size for class icon
  • It is better with a transparent background
  • It should not have borders
  • Provide the relative path to a svg or png file, located somewhere on your iTop.
  • You can also reference a fileref provided in the XML encoded in base64
If you add an icon through an extension on a class which is part of another module, use a relative path as done above

In this example, the FAQCategory class is defined in the module itop-faq-light and my icon is located under my own extension folder my-extension-code/images/

Here is the result:

Icon with fileref

  • Use an online tool to encode your icon in base64 for eg this one
  • Create within the datamodel.xxxx.xml file this XML structure:
    <class id="xxxx">
          <!--Here we specify an icon which is included in the XML as a file -->
          <icon _delta="define">
            <fileref ref="my-image-unique-id"/>
    <file id="my-image-unique-id" xsi:type="File"_delta="define">
      <!-- Copy here the result of the base64 conversion. It's very long -->

Class colors

Within the datamodel.xxxx.xml file, in a style tag to the class properties

  • Add colors tags can contain a CSS formatted color,
    • You can use a color code: #689F38FF
    • Better you can use existing iTop CSS variable, which are part of the iTop theme, using this syntax:
    • $ibo-color-blue-400
    • $ibo-transparent
    • $ibo-body-text-color default color of iTop text
    • $ibo-field--value--color color of the text of a field (in form and list)
itop-design / classes / class@xxx / properties
    <style _delta="define">
      <!--Specify an optional icon for your class (relative path from iTop root)-->
      <!-- Main optional color for the class, any valid CSS color (hexa, hsla, variable) or an SCSS variable --> 

Here is the result of that setting in iTop, when done on UserRequest class:

Object icon

It is also possible to have a different icon for each instance of a Class. It is used for the Person class, with a picture or an avatar different for each person. It can be used on otyher classes, but the class must have an Image field to store that instance dependent information.

For this you need to alter the XML of the class within the datamodel.xxxx.xml file of your extension. The syntax to use is quite simple :

itop-design / classes / class@xxx
        <fields_semantic _delta="define">
          <!-- Specify the attribute code of an AttributeImage within the class -->

The result is:

XML full example

Here is a full example of the 3 customizations all in one, on the Location class

itop_design | classes
    <class id="Location" _delta="must_exist">
          <state_attribute _delta="redefine">type</state_attribute>
          <image_attribute _delta="define">image</image_attribute>
          <main_color _delta="define">#00ff00</main_color>
        <field id="type" xsi:type="AttributeEnum" _delta="define">
            <value id="campus">
              <code>campus</ code>
            <value id="building">
              <code>building</ code>
            <value id="floor">
              <code>floor</ code>
            <value id="room">
              <code>room</ code>
        <field id="image" xsi:type="AttributeImage" _delta="define">
            <item id="type"  _delta="define">
            <item id="image"  _delta="define">
3_2_0/customization/class-colors.txt ยท Last modified: 2024/06/20 17:28 (external edit)
Back to top
Contact us