2
votes

I'm working to customize liferay's Calendar portlet and have created a hook for this.

I want to show all the "Related Assets" associated with a Calendar Event directly in the list page itself where all the Events are displayed instead of the Event's detail view page.

Currently liferay shows the "Related Assets" only when we click on the Event to view the details of that Event.

enter image description here

Can anyone help me?

Environment: Liferay 6.1

Thanks a lot Sabrina

1
"know all the Related Assets", what would this mean?Prakash K
Do you know when you create a new calendar event, you can link to the event one or more document, then when you open the event in details you can see below the start-date, end-date, description also the "Related Assets", in the case of a basic document it contains the list of the document item. I would like to do that in the calendar first page without open a new windows.. I don't know if I'm enough clear, write for more information.. ThanksSabrina
I have edited your question. Can you check if I have understood the requirement correctly.Prakash K
Yes, it is exactly what I need!! Do you know how I could do with hook?Sabrina

1 Answers

2
votes

I assume you already have liferay's source code and you know how to create a hook.

The JSPs you would be modifying would be in this path:

portal-web/docroot/html/portlet/calendar

So here are some steps to help you solve your query:

  1. You need to modify the event_iterator.jspf: row.addText(event.getTitle(), rowURL);
  2. You have to adjust the following code taken from view_event.jsp in event_iterator.jspf.

    <% 
    AssetEntry layoutAssetEntry = AssetEntryLocalServiceUtil.getEntry(CalEvent.class.getName(), event.getEventId());
    %>
    
    <%-- <liferay-util:buffer> is a tag which stores all that is written inside
         its body in a single variable string, in this case "relatedAssetsLinksBuffer"
    --%>
    
    <liferay-util:buffer var="relatedAssetsLinksBuffer">
        <c:if test="<%= enableRelatedAssets %>">
                <%=event.getTitle() %>
            <div class="entry-links">
                <liferay-ui:asset-links
                    assetEntryId="<%= layoutAssetEntry.getEntryId() %>"
                />
            </div>
        </c:if>
    </liferay-util:buffer>
    
  3. Now the line in step-1 becomes: row.addText(relatedAssetsLinksBuffer, rowURL);

I have not tried this but I think it would work or will atleast give you some help in solving your query.

Tip for Hooks (might be useful in future): Liferay follows a convention in storing its JSPs, so for custom-jsps Hook (i.e. a hook created for modifying liferay's JSP) you just need to search for that particular JSP & modify it.

For Eg: You wanted to modify the first page of calendar portlet. So liferay portlet's first page is always view.jsp located in the folder with the same name as the portlet-name in this case "Calendar" and view.jsp will contain some tags like <%@ include /> or <liferay-util:include /> which would include other files to show the content. So you can always start with a view.jsp and navigate ahead. By the way the names of the JSPs are also most of the time self-explanatory.

Hope this helps.