Question

The site-logo appears from the theme using the code in portal_normal.vm:

<img alt="$logo_description" height="$site_logo_height" src="$site_logo" width="$site_logo_width" />

I want to know the value of the variable $site_logo in my custom plugin portlet.

I am showing all the sites in a list and want to show the different logos for public and private pages besides the site-name.

Any pointers would help.

Thanks

Was it helpful?

Solution

Basically, liferay shows image logo from ThemeDisplay object.

I tried looking at ServicePreAction.java where themeDisplay object gets prepared, I found below things that would be helpful to you.

Using code below you can get logourl for any Site's Public or Private pages which you can set to html image tag.

LayoutSet siblingLayoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
                                groupId, isPrivatePages);

if (siblingLayoutSet.isLogo()) {
    logoId = siblingLayoutSet.getLogoId();
}

StringBundler sb = new StringBundler(5);
String imagePath=PortalUtil.getPathImage();
sb.append(imagePath);
sb.append("/layout_set_logo?img_id=");
sb.append(logoId);
sb.append("&t=");
sb.append(WebServerServletTokenUtil.getToken(logoId));

layoutSetLogo = sb.toString();

OTHER TIPS

There is a simpler way:

String logoPath = PortalUtil.getPortalURL(themeDisplay) + themeDisplay.getLayoutSetLogo();

I am using Liferay 7.3.1. If you want to use the uploaded logo (public pages -> logo) in your theme, do the following:

in templates/init_custom.ftl (If you don't have this file, create it)

<#assign logo_img_path = themeDisplay.getLayoutSetLogo()/>

in header.ftl or whatever your file is add

<img
    src="${logo_img_path}"
    alt="My logo"
    title="My site"
/>

I provided this answer,because someone may found useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top