Pergunta

I would like to show some site page urls in a Liferay jsp portlet. I'm using Liferay 6.1 EE. I would like to use page's localized title and other custom fields added (e.g. cssClass).

I have done the same for the navigation bar, for my velocity theme:

#if (!$page_group.isUser())

    #set($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))

    <ul id="quickLinks">
        <li>
            #set($currFriendlyUrl = "/i-want-to")
            #set($currLayout = $layoutLocalService.getFriendlyURLLayout($group_id, true, $currFriendlyUrl))
            <a href="$currLayout.getRegularURL($request)" $currLayout.getTarget() class="$currLayout.getExpandoBridge().getAttribute('cssClass')">$currLayout.getName($locale)</a>
        </li>
    </ul>
#end

How could I write the same code using jsp?

I have found a similar quesion, but there was not a clear code example for jsp in answers.

Foi útil?

Solução

Managed to implement it with jsp as follows:

<%@ page import="com.liferay.portal.service.LayoutLocalServiceUtil" %>
<% if (!layout.getGroup().isUserGroup()) { %>
    <ul id="quickLinks">
        <li>
            <% Layout currLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(scopeGroupId, true, "/i-want-to"); %>
            <a href="<%=currLayout.getRegularURL(request)%>" <%=currLayout.getTarget()%> class='<%=currLayout.getExpandoBridge().getAttribute("cssClass")%>'><%=currLayout.getName(locale)%></a>
        </li>
    </ul>
<% } %>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top