سؤال

I'm trying to create a link in a Liferay template using Velocity.

My code is the following, based on several examples on the net:

#set ($plid = $getterUtil.getLong($request.get('theme-display').get('plid')))

#set ($u = $portletURLFactory.create($request,"1",$plid,"RENDER_PHASE"))
$u.setParameter("struts_action","/asset_publisher/applyForJob");

<a href="$u">yyy</a>

I get the plid value, but my URL will be just ending with $u, it seems that the $portletURLFactory.create() method is not properly interpreted.

Any ideas? Thank you!

هل كانت مفيدة؟

المحلول

Are you trying to do this inside Web Content Template? In that case it will not work because you do not have access to the real http request object. You need to create this link using javascript instead. Here is a code snippet.

<script type="text/javascript">
function createURL() {
    AUI().ready('liferay-portlet-url', function(A) {
        var renderURL = Liferay.PortletURL.createRenderURL();
        renderURL.setParameter("struts_action","/asset_publisher/applyForJob");
        renderURL.setPortletId("1");
        renderURL.setPortletMode("view");
        renderURL.setWindowState("normal");
        window.location = renderURL.toString();
    });
}
</script>
<a href="javascript: createURL(); ">Go</a>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top