Tuesday, 3 February 2015

How Sitecore manages icons

Introduction


Any Sitecore developer knows that building a Sitecore solution is 20% writing code and 80% choosing icons.  You might not have given icon management any thought, but not only is it possible to create your own icons for use with Sitecore, but there are already more icons available to you than you think.


The Icon Editor


In order to configure an icon for an item, select the item via the Content Editor and then select Icon from the Configure menu.  You can also open up the Icon Selector by clicking on the item's icon in the Content tab (where it appears next to the item's name); this is often quicker than having to select the Configure menu.

When you configure an icon for something you'll get this familiar dialog


Icon selector
I currently have the "About" icon configured which is in the "Applications" section.  Open up Windows Explorer and navigate to this folder in your solution;

\sitecore\shell\Themes\Standard

In there you will see zip files such as Applications.zip, Business.zip, Control.zip etc.  These are the files Sitecore uses to store its icons.  If you open one up you'll see there is a root folder with the same name as the zip file, and inside that are folders such as 32x32, 64x64 etc, and in each folders are the icons themselves.  So in Applications.zip you'll find a file called

\Applications\32x32\About.png

which is the file I have selected above.  If Sitecore needs to show this as a 16x16 icon it can find the relevant file in the 16x16 folder instead.

Additional zip files


Look closely in the Standard folder and you'll also see the likes of ApplicationsV2.zip, BusinessV2.zip etc, and inside those zip files you'll see the standard Sitecore icon folder structure.  The reason you don't see an "ApplicationsV2" option in the dropdown is because that dropdown has its values hard-coded inside Sitecore, it isn't dynamically reading all available zip files.  Just because it doesn't show in the dropdown doesn't mean you can't manually update the path in the "Icon" field though.  So amend it like so and click ok


The icon has changed accordingly


The V2 versions of icons tend to be a bit more metallic and less cartoon-like than the originals.  If you unzip the icon file and view the folder as icons via Windows Explorer you can get an idea of how they look.

Creating your own icons


As we have seen above, Sitecore simply looks inside the zip file that has the same name as the root of your icon path, and then looks inside the relevant size folder to display the chosen icon.  If you want to create your own icons create a folder called something like MyIcons, then create the relevant size folders inside it (16x16, 32x32 etc), and inside each size folder put an icon of the appropriate size for the folder.  Zip the folder into a file called MyIcons.zip and put the zip file in Standard folder with all of the others.  In the Icon Selector supply the path to your icon by entering it directly into the Icon box in the Icon Selector.

MyIcons/32x32/MyIcon.png

1 comment:

  1. Have to stress out that the archive has to have all the folders for the different sizes and the icons have to have version for all the different sizes. No need to restart Sitecore/iis while changing the item, but it looks like it is needed when changing/addding the zip file with the icons.

    ReplyDelete