掲示板

Most Viewed Page

thumbnail
15年前 に Hugo Alvarado によって更新されました。

Most Viewed Page

New Member 投稿: 11 参加年月日: 09/03/23 最新の投稿
Hello everyone,
Perhaps this is a really simple question but I cant find it anywhere, I wanted to show (say on home page) in a portlet the Most Visited Page(s) of my portal, I know i can use Asset Publisher to show for instance a most viewed Journal Article but I can't find anything related to pages, not just content. Any thoughts would be really nice.

Thanks.
thumbnail
15年前 に Amos Fong によって更新されました。

RE: Most Viewed Page

Liferay Legend 投稿: 2047 参加年月日: 08/10/07 最新の投稿
Hey Hugo,

Currently Liferay does not record hits to each page but there is a ticket open with a contribution from Mauro here. Maybe that will be useful to you and hopefully implemented in Liferay core sometime.
thumbnail
15年前 に Hugo Alvarado によって更新されました。

RE: Most Viewed Page

New Member 投稿: 11 参加年月日: 09/03/23 最新の投稿
Hi Amos, I'm going to take a look.
Thank you!
thumbnail
10年前 に priti parmar によって更新されました。

RE: Most Viewed Page

New Member 投稿: 24 参加年月日: 10/11/29 最新の投稿
Hi ,

In liferay 6.1 , we can use expando attribute of pages , and using a servicepreaction hook we can modify the value of view count.

here is the code for this:

public class CustomServicePreAction extends Action {

/**
* This Method is used for Creating the Map Variable of the Pages
*
* @param HttpServletRequest
* @param HttpServletResponse
*/
@Override
public void run(HttpServletRequest req, HttpServletResponse res)
throws ActionException {

ThemeDisplay themeDisplay = (ThemeDisplay) req
.getAttribute(WebKeys.THEME_DISPLAY);
if (!themeDisplay.getURLCurrent().contains("control_panel")) {
Layout layout = themeDisplay.getLayout();
try {
setupExpandos(layout);
} catch (Exception e) {

}
}

}

protected void setupExpandos(Layout layout) throws Exception {


ExpandoTable table = null;
try {
table = ExpandoTableLocalServiceUtil.addTable(layout.getCompanyId(), Layout.class.getName(),ExpandoTableConstants.DEFAULT_TABLE_NAME);
} catch (DuplicateTableNameException dtne) {
table = ExpandoTableLocalServiceUtil.getTable(layout.getCompanyId(), Layout.class.getName(),ExpandoTableConstants.DEFAULT_TABLE_NAME);
}
String column = "viewCount";
ExpandoColumn expcolumn = null;
try {
expcolumn = ExpandoColumnLocalServiceUtil.addColumn(table.getTableId(), column,ExpandoColumnConstants.LONG,0L);
}
catch (DuplicateColumnNameException dcne)
{
expcolumn = ExpandoColumnLocalServiceUtil.getColumn(layout.getCompanyId(),PortalUtil.getClassNameId(Layout.class.getName()), table.getName(), column);
}
long count = Long.valueOf(ExpandoValueLocalServiceUtil.getData(layout.getCompanyId(),Layout.class.getName(), table.getName(), expcolumn.getName() , layout.getPrimaryKey(),0L));
ExpandoValueLocalServiceUtil.addValue(layout.getCompanyId(),Layout.class.getName(), table.getName(), expcolumn.getName() , layout.getPrimaryKey(),count+1L);
}
}