문제

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

도움이 되었습니까?

해결책

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();

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top