Reputation: 11
I have a Liferay 7 project and I would like to change the favicon of the browser to a custom one. I created a portal-ext.properties file and I set the property theme.shortcut.icon=myfavicon.ico
. Although, I cannot see the custom icon on my website.
Could you please tell me where to put my .ico file in the tomcat dir? What is the path for the theme.shortcut.icon
to my image?
Also, where do you suggest to put the portal-ext.properties file?
Upvotes: 1
Views: 3986
Reputation: 48067
The icon should be part of your theme. Here's how to figure out what to do: Check Liferay's source code (I have the 7.1 sourcecode here), the results are quite easy to browse through, but I'm shortening the grep output here for clarity:
olaf@tp:~/src$ grep -r "theme.shortcut.icon" .
./portal-kernel/.../PropsKeys.java: public static final String THEME_SHORTCUT_ICON = "theme.shortcut.icon";
./portal-impl/src/portal.properties: theme.shortcut.icon=favicon.ico
...
olaf@tp:~/src$ grep -r "THEME_SHORTCUT_ICON" .
./portal-web/.../themes/top_head.jsp:<link data-senna-track="temporary" href="<%= themeDisplay.getPathThemeImages() %>/<%= PropsValues.THEME_SHORTCUT_ICON %>" rel="Shortcut Icon" />
As it's hard to read, despite shortening the lines, the shortcut icon path is constructed as <%= themeDisplay.getPathThemeImages() %>/<%= PropsValues.THEME_SHORTCUT_ICON %>
. In the interest of easy maintainability, I'd suggest to build your own theme (almost everybody does this anyway) and just use the standard filename and replace that image in your theme, and you'll be set.
As you ask about "where to put the image in tomcat": In Liferay, you shouldn't expect to serve regular web applications, in fact, themes are typically served from their OSGi contents. You can easily check this by going to the served page and search for favicon
: If the path contains a /o/
, this points to the OSGi engine to serve it, e.g. there's not an equivalent in the Tomcat filesystem (it's bad practice to mock around with those files anyways: Most likely you'll forget them during the next upgrade and loose your changes.
Looking at my stock installation, http://localhost:8080/o/classic-theme/images/favicon.ico
is the place that the favicon is served from, and indeed, there's that /o/
. So the answer is: Add the icon to your own theme, then you don't even need to change its name through the property you found.
But how to create a well maintainable system, with properly separated content (between yours and stock Liferay) is probably out of scope for this answer.
As an extreme, non-recommended, quickfix you might want to set the value in portal-ext.properties to
theme.shortcut.icon=../../../myfavicon.ico
and replace the icon in tomcat's webapps/ROOT/myfavicon.ico
. But don't come crying later, when you accidentally overwrite it in an upgrade.
Upvotes: 1