spriteIconDocu.txt

Administrator Admin, 2010-01-31 16:50

Download (9.1 kB)

 
1
SPRITE ICON API
2

    
3
The sprite icons are a completely different approach than using single file images. In order to get a
4
icon you don't need to know anything about a file or whatever. The only thing you need to know are the
5
css classes used. This api even helps you with that by only needing a single string name for an icon.
6
You should always look up this "iconName" in the Skinning Manual.
7

    
8
Example: display an icon for creating a new document/page content element
9
Usage:   t3lib_iconWorks::getSpriteIcon('actions-document-new');
10
Result:  <span class="t3-icon t3-icon-actions-document t3-icon-document-new ">&nbsp;</span>
11

    
12
== Common Options == 
13

    
14
If you want to change additional options you can provide them as an config array. Some options are
15
  - 'title'   (string: defaults to '') define an title for the icon [if the icon is wrapped by a link for functionality the link should get the title]
16
  - 'class'   (string: defaults to '') additional css classes to add
17
  - 'row'     (array:  no default)     data row; not added as attribute
18
  - [...] more Options are in the Advanced Section
19

    
20
Example: new Record icon with a title tag
21
Usage:   t3lib_iconWorks::getSpriteIcon('actions-document-new', 'Create new Record');
22
Usage:   t3lib_iconWorks::getSpriteIcon('actions-document-new', array('titel' => 'Create new Record') );
23
Result:  <span class="t3-icon t3-icon-actions-document t3-icon-document-new" title="Create new Record">&nbsp;</span>
24
Note:    The title is a special case and can also be provided as string for the second parameter
25

    
26
Example: new Record icon with an additional css class
27
Usage:   t3lib_iconWorks::getSpriteIcon('actions-document-new', array('class' => 'center') );
28
Result:  <span class="t3-icon t3-icon-actions-document t3-icon-document-new center">&nbsp;</span>
29

    
30
Example: new Record icon with an additional css class and title tag
31
Usage:   t3lib_iconWorks::getSpriteIcon('actions-document-new', array('class' => 'center', 'titel' => 'Create new Record') );
32
Result:  <span class="t3-icon t3-icon-actions-document t3-icon-document-new center" title="Create new Record">&nbsp;</span>
33

    
34

    
35
== Overlays ==
36

    
37
Overlays are realised by placing two spans on top of each other. For easy usage you can just add
38
overlays with '+'.
39

    
40
Example: icon of a hidden page (page icon with overlay hidden)
41
Usage:   t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-default+status-overlay-hidden');
42
Result:  <span class="t3-icon t3-icon-apps-pagetree t3-icon-pagetree-page-default">
43
           <span class="t3-icon t3-icon-status-overlay t3-icon-overlay-hidden t3-icon-overlay">&nbsp;</span>
44
         </span>
45

    
46
== Files ==
47

    
48
Icons for files are generated with a 'file:' prefix followed by the complete path or the filename.
49

    
50
Example: icon for an image
51
Usage:   t3lib_iconWorks::getSpriteIcon('file:EXT:t3skin/icons/options.gif');
52
Result:  <span class="t3-icon t3-icon-mimetype-media t3-icon-media-image">&nbsp;</span>
53

    
54
If you already know the fileextension or the type of the path you can use 'file::'
55

    
56
Example: icon for a *.png file
57
Usage:   t3lib_iconWorks::getSpriteIcon('file::gif');
58
Result:  <span class="t3-icon t3-icon-mimetype-media t3-icon-media-image">&nbsp;</span>
59
Note:    The result is the same as gif and png files are mapped to the same icon
60

    
61
Example: icon for a folder
62
Usage:   t3lib_iconWorks::getSpriteIcon('file:EXT:t3skin/icons');
63
Usage:   t3lib_iconWorks::getSpriteIcon('file:/');
64
Usage:   t3lib_iconWorks::getSpriteIcon('file::folder');
65
Result:  <span class="t3-icon t3-icon-apps-filetree t3-icon-filetree-folder-default">&nbsp;</span>
66

    
67
Example: icon for mountpoint
68
Usage:   t3lib_iconWorks::getSpriteIcon('file::mount');
69
Result:  <span class="t3-icon t3-icon-apps-filetree t3-icon-filetree-mount">&nbsp;</span>
70

    
71
== Table Rows ==
72

    
73
Icons for table rows are generated with a 'row:' prefix followed by the table and an option array with 'row'
74

    
75
Example: generate icon for current table and row
76
Usage:   t3lib_iconWorks::getSpriteIcon('row:' . $table, array('row' => $row) );
77
Result:  <span class="t3-icon t3-icon-apps-pagetree t3-icon-pagetree-page-not-in-menu">&nbsp;</span>
78
Note:    Depending on table and row (here $table = pages; $row = Array( [doktype] => 254 [...] )
79

    
80
If you want to have the table row overlay icon you can use 'row::' again with the option array 'row'.
81
In order to have it automatically with the icon you can use the '+' mentioned earlier.
82

    
83
Example: generate icon + overlay for current table and row
84
Usage:   t3lib_iconWorks::getSpriteIcon('row:' . $table . '+row::' . $table, array('row' => $row));
85
Result:  <span class="t3-icon t3-icon-apps-pagetree t3-icon-pagetree-page-not-in-menu">
86
           <span class="t3-icon t3-icon-status-overlay t3-icon-overlay-hidden t3-icon-overlay">&nbsp;</span>
87
         </span>
88

    
89
== Advanced Section ==
90

    
91
Every string item that is in the option array for getSpriteIcon is automatically added as a html attribute. So you can add
92
whatever valid or nonvalide html attribute. There are a few options predefined and some are not added as attribute:
93
  - 'row'     (array:  no default)           data row; not added as attribute
94
  - 'element' (string: defaults to 'span')   the html element that should be created; not added as attribute
95
  - 'html'    (string: defaults to '&nbsp;') html content that should be placed inside the tag; not added as attribute
96
  - 'baseCssClass' (string: defaults to 't3-icon') change the base class for the icon type; not added as attribute
97

    
98
Example: generate a uppercase text link to google with the external link icon
99
Usage:   t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-shortcut-external', array(
100
           'element' => 'a',
101
           'html' => 'google',
102
           'href' => 'http://www.google.com',
103
           'style' => 'text-transform: uppercase'
104
         ));
105
Result: <a style="text-transform: uppercase;" href="http://www.google.com" class="t3-icon t3-icon-apps-pagetree t3-icon-pagetree-page-shortcut-external">google</a>
106
Note:   Text options get transformed to html elements
107

    
108
In fact you can define multiple '+' in the iconname and for each part you can define a different configuration.
109
For this you need to use a multidimentional array. The default configuration is set to
110
  $TYPO3_CONF_VARS['BE']['iconDefaultOptions'] => array(
111
   array('element' => 'span', 'baseCssClass' => 't3-icon', 'html' => '&nbsp;'),
112
   array('element' => 'span', 'baseCssClass' => 't3-icon', 'html' => '&nbsp;', 'class' => 't3-icon-overlay')
113
  )
114
so if you want more then two level you will have to define that in your config. However this is very unlikely.
115

    
116
Example: link to google with external icon and overlay hidden - some text in the span
117
Usage:   t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-shortcut-external+status-overlay-hidden', array(
118
           array('element' => 'a', 'href' => 'http://www.google.com'),
119
           array('html' => 'V')
120
         ));
121
Result:  <a class="t3-icon t3-icon-apps-pagetree t3-icon-pagetree-page-shortcut-external" href="http://www.google.com">
122
           <span class="t3-icon t3-icon-status-overlay t3-icon-overlay-hidden t3-icon-overlay">V</span>
123
         </a>
124

    
125
== Overlays ==
126

    
127
This system is supposed to be only used with one overlay. The graphical icon guideline shows that subtypes of icons
128
are defined through a overlay in the right bottom corner. The left bottom area is then used to show the most important
129
state of the icon (just one). If the element has more than one state it will be displayed on hover currently just with
130
text in the title tag - hopefully in the future with with some javascript overlay containing icons.
131
In order to select the most important state there is a priority list at
132
  $TYPO3_CONF_VARS['BE']['iconOverlayPriorities'] => array('hidden', 'starttime', 'endtime', 'fe_group', 'protectSection', 'futuretiming')
133
As multiple states may have the same icon and the state name is not compatible with the css there is a mapping array at
134
  $TYPO3_CONF_VARS['BE']['iconOverlayMapping'] = 
135
    'hidden'       => 'status-overlay-hidden',
136
    'fe_group'     => 'status-overlay-access-restricted',
137
    'starttime'    => 'status-overlay-scheduled',
138
    'endtime'      => 'status-overlay-scheduled',
139
    'futuretiming' => 'status-overlay-scheduled',
140
    'readonly'     => 'status-overlay-locked',
141
    'deleted'      => 'status-overlay-deleted',
142
    'missing'      => 'status-overlay-missing',
143
    'translated'   => 'status-overlay-translated',
144
    'protectedSection' => 'status-overlay-includes-subpages',
145
  )
146

    
147
== Table Row Icons ==
148

    
149
In order to generate a proper iconname for table rows you need to add the following configuration for you table.
150
This is an example for the table pages:
151
  $TCA['pages']['typeicon_classes'] = array(
152
    '1' => 'apps-pagetree-page-default',
153
    '3' => 'apps-pagetree-page-shortcut-external',
154
    '255' => 'actions-edit-deleted',
155
    ...
156
  )
157
The array can be anything (doesn't need to be a number) it depends an  $TCA['pages']['typeicon_column']
158
Another example from tt_content:
159
  $TCA['tt_content']['typeicon_classes'] = array(
160
    'header' => 'mimetypes-x-content-header',
161
    'textpic' => 'mimetypes-x-content-text-picture',
162
    'image' => 'mimetypes-x-content-image',
163
    ...
164
  )
165

    
166