on 03-18-2015 10:58 AM
If it is enough that you replace named SAP icons with your custom icons (accessible under the original name), .
You could also do this with a custom tile.
But if you want to 'simply' add your custom icon font to those supplied by SAP and use it on a standard tile on the FLP, here (below) is how you can do it.
Warning: this solution seems to be stretching the limits of the current FLP implementation quite a bit. Its supportability across SAP upgrades is not assured.
In short:
Step-by-step:
METHOD if_http_extension~handle_request.
CALL METHOD super->if_http_extension~handle_request
EXPORTING
server = server.
DATA(lv_relative_path_exp) = server->request->get_header_field( if_http_header_fields_sap=>path_info_expanded ).
DATA(lv_relative_path_exp_lc) = lv_relative_path_exp.
TRANSLATE lv_relative_path_exp_lc TO LOWER CASE. " ABAP is case insensitive although URLs by standard are case sensitive
" E.g.: /ui2/ushell/shells/abap/fiorilaunchpad.html
IF lv_relative_path_exp_lc CP '*fiorilaunchpad.html'.
DATA(lv_content_as_string) = server->response->get_cdata( ).
IF lv_content_as_string IS NOT INITIAL.
DATA(lv_mycustom_font_css) = | <style type="text/css">\n| &&
|@font-face \{\n| &&
| /* Icon and Icon Pool */\n| &&
| /* https://help.sap.com/saphelp_uiaddon20/helpdata/en/21/ea0ea94614480d9a910b2e93431291/content.htm */\n| &&
| font-family: 'MyCustom-icons';\n| &&
| src: url('/sap/public/bc/WebIcons/zmycustom/MyCustom-icons.ttf') format('truetype');\n| &&
| font-weight: normal;\n| &&
| font-style: normal;\n| &&
|\}\n| &&
| </style>\n\n|.
DATA(lv_custom_flp_html) = lv_mycustom_font_css && | <!-- iPhone splash screens -->|.
REPLACE FIRST OCCURRENCE OF '<!-- iPhone splash screens -->' IN lv_content_as_string WITH lv_custom_flp_html.
" Add custom icons (icon font)
DATA(lv_mycustom_icon_font_js) = |// Register MyCustom icon font\n| &&
| sap.ui.core.IconPool.addIcon('goods-receipt', 'mycustom', 'MyCustom-icons', 'e000', false, true);\n|.
DATA(lv_custom_icons) = lv_mycustom_icon_font_js && | sap.ushell.iconfonts.registerFiori2IconFont();|.
REPLACE FIRST OCCURRENCE OF 'sap.ushell.iconfonts.registerFiori2IconFont();' IN lv_content_as_string WITH lv_custom_icons.
" Consider parent's comment:
" "extracted to separate method, because we need an ATC exemption for false positive XSS error"
server->response->set_cdata( lv_content_as_string ).
ENDIF.
ENDIF.
ENDMETHOD.
/sap/opu/odata/UI2/PAGE_BUILDER_CUST/PageChipInstances(pageId='X-SAP-UI2-CATALOGPAGE%3A<Z_your_FLP_catalog>',instanceId='<tile_instance_id>')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can add custom icon fonts to sap.ui.core.IconPool
refer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
This is applicable for a particular application. I am looking for a solution which works globally.
For example, if a icon is used for multiple applications.
If we somehow add this to the icon library from where the icon comes as default then we won't need to add any CSS I guess.
We can add this icon in a normal way what we do for the default icons available in the icon list.
If anyone has implemented this, please let me know.
Regards,
Gaurav
Hi Hazam,
You can replace the standard icon with a custom one following below easy steps:
div[title='Launch "<title_of_your_tile>"'] > span[aria-label="sap-logo-shape"] {
bottom: 27px !important;
}
div[title='Launch "<title_of_your_tile>"'] > span[aria-label="sap-logo-shape"]:before {
background-image: url("../../../../../Base/baseLib/<your_custom_theme>/img/misc/<your_image>.png") !important;
background-size: 38px 38px !important;
display: inline-block;
width: 38px;
height: 38px;
content: " ";
}
7. Create a .zip archive and upload the custom theme
That's all! Refresh your page and new icon will appear!
Find in attachment my result on Fiori Luanchapd.
BR
Luca
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hazam,
I was fighting with this issue and I started of with the link from Simon.
After a while I figured it out.
In order to be able to use you own Font you have to:
1. Create a folder in the CSS folder called: fonts
2. Upload your TTF and EOT files there
3. Add in the css:
@font-face {
font-family: 'MY-icons';
src: url('fonts/My-Library.ttf'),
url('fonts/My-Library.eot');
font-weight: normal;
font-style: normal;
}
4. Add the icons you need in the JS file:
sap.ui.core.IconPool.addIcon("icon-name", "my-icons", "My-icons", "e65c");
the uri to your icon will be: sap-icon://my-icons/icon-name
and use the setIcon method to set it to a button or somewhere else.
Regards,
Ilina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi IIina,
Please can you let me know which of the JS file are you referring to.
Is it IconPool.js?
Please can you let me know the process of modification of this file and what is its location.
I need to use a custom icon for the tiles on launchpad and want this to be available on global level rather than for a particular application.
Regards,
Gaurav
Hello,
I was looking for the same functionality.
I didn't found any "easy" solution.
Please have a look to SAP help:
Using Icon Font in SAPUI5 - User Interface Add-On for SAP NetWeaver - SAP Library
The trick is to enhance the CSS style and reference your own icons.
I'll try it later on.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.