Liferay自带的CMS功能能满足常规的文章发布,审核等需求,但表现实在有点外国化,修改至如下

点击more 最大化,并在底部显示分页栏

并且在文章中 增加文章标题
需要修改portlet/journal_article/view.jsp,SearchContainer标签的page.jsp(taglib/ui/search_iterator/page.jsp)
view.jsp 修改至如下
<%@ include file="/html/portlet/journal_articles/init.jsp" %>
<%
String articleId = ParamUtil.getString(request, "articleId");
double version = ParamUtil.getDouble(request, "version");
%>
<c:choose>
<c:when test="<%= Validator.isNull(articleId) %>">
<%
if (Validator.isNull(type)) {
type = null;
}
String status = "approved";
PortletURL portletURL = renderResponse.createRenderURL();
if (pageURL.equals("normal")) {
portletURL.setWindowState(WindowState.NORMAL);
}
else {
portletURL.setWindowState(WindowState.MAXIMIZED);
}
portletURL.setParameter("struts_action", "/journal_articles/view");
PortletURL articleURL = PortletURLUtil.clone(portletURL, renderResponse);
ArticleSearch searchContainer = new ArticleSearch(renderRequest, portletURL);
searchContainer.setDelta(pageDelta);
searchContainer.setOrderByCol(orderByCol);
searchContainer.setOrderByType(orderByType);
searchContainer.setOrderByComparator(orderByComparator);
List headerNames = searchContainer.getHeaderNames();
headerNames.clear();
headerNames.add("name");
// headerNames.add("display-date");
// headerNames.add("author"); luob
searchContainer.setOrderableHeaders(null);
ArticleSearchTerms searchTerms = (ArticleSearchTerms)searchContainer.getSearchTerms();
searchTerms.setGroupId(groupId);
searchTerms.setType(type);
searchTerms.setStatus("approved");
%>
<%@ include file="/html/portlet/journal/article_search_results.jspf" %>
<%
List resultRows = searchContainer.getResultRows();
for (int i = 0; i < results.size(); i++) {
JournalArticle article = (JournalArticle)results.get(i);
article = article.toEscapedModel();
ResultRow row = new ResultRow(article, article.getArticleId() + EditArticleAction.VERSION_SEPARATOR + article.getVersion(), i);
String rowHREF = null;
if (pageURL.equals("popUp")) {
StringBuilder sb = new StringBuilder();
sb.append(themeDisplay.getPathMain());
sb.append("/journal_articles/view_article_content?groupId=");
sb.append(article.getGroupId());
sb.append("&articleId=");
sb.append(article.getArticleId());
sb.append("&version=");
sb.append(article.getVersion());
rowHREF = sb.toString();
}
else {
articleURL.setParameter("groupId", String.valueOf(article.getGroupId()));
articleURL.setParameter("articleId", article.getArticleId());
articleURL.setParameter("version", String.valueOf(article.getVersion()));
rowHREF = articleURL.toString();
}
String target = null;
if (pageURL.equals("popUp")) {
target = "_blank";
}
TextSearchEntry rowTextEntry = new TextSearchEntry(SearchEntry.DEFAULT_ALIGN, SearchEntry.DEFAULT_VALIGN, article.getArticleId(), rowHREF, target, null);
/*// Article id
row.addText(rowTextEntry);
// Version
rowTextEntry = (TextSearchEntry)rowTextEntry.clone();
rowTextEntry.setName(String.valueOf(article.getVersion()));
row.addText(rowTextEntry);*/
// Title
rowTextEntry = (TextSearchEntry)rowTextEntry.clone();
//修改 文章Title缩略和日期显示
String title = "";
if (article.getTitle().length()>18)
{
title = article.getTitle().substring(0,18)+"
";}
else
title = article.getTitle();
title = title + " ("+dateFormatDateTime.format(article.getDisplayDate())+")";
rowTextEntry.setName(title);
row.addText(rowTextEntry);
// Display date
// rowTextEntry = (TextSearchEntry)rowTextEntry.clone();
// rowTextEntry.setName(dateFormatDateTime.format(article.getDisplayDate()));
// row.addText(rowTextEntry);
// rowTextEntry = (TextSearchEntry)rowTextEntry.clone();
// rowTextEntry.setName(PortalUtil.getUserName(article.getUserId(), article.getUserName()));
// row.addText(rowTextEntry);
// Add result row
resultRows.add(row);
}
%>
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
<%
//luob 2008 12 10 如果当前是windowstate是最大化 设置最大条目为20 并显示分页栏
if (renderRequest.getWindowState().equals(WindowState.MAXIMIZED)) {
searchContainer.setDelta(20);
%>
<div class="taglib-search-iterator-page-iterator-top">
<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
</div>
<% } else {%>
<a href="<portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" />">more</a>
<% };%>
</c:when>
<c:otherwise>
<%
try {
String languageId = LanguageUtil.getLanguageId(request);
String content = JournalArticleServiceUtil.getArticleContent(groupId, articleId, version, languageId, themeDisplay);
System.out.println(content);
//luob 2008 12 10 add article title 在文章页面增加 title
JournalArticle article = JournalArticleServiceUtil.getArticle(groupId,articleId,version);
String title = "  <tr><td class='bigfont' align='center' Style='font-weight:bold;font-size: 16px;'>"+article.getTitle()+"</td></tr>  <hr width='100%' size='3'>";
RuntimeLogic portletLogic = new PortletLogic(application, request, response, renderRequest, renderResponse);
RuntimeLogic actionURLLogic = new ActionURLLogic(renderResponse);
RuntimeLogic renderURLLogic = new RenderURLLogic(renderResponse);
content = RuntimePortletUtil.processXML(request, content, portletLogic);
content = RuntimePortletUtil.processXML(request, content, actionURLLogic);
content = RuntimePortletUtil.processXML(request, content, renderURLLogic);
%>
<%= title %>
<%= content %>
<%
}
catch (PrincipalException pe) {
%>
<span class="portlet-msg-error">
<liferay-ui:message key="you-do-not-have-the-required-permissions" />
</span>
<%
}
%>
</c:otherwise>
</c:choose>
<a href="<portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" />">more</a>
Page.jsp修改至如下
<%@ include file="/html/taglib/init.jsp" %>
<%
SearchContainer searchContainer = (SearchContainer)request.getAttribute("liferay-ui:search:searchContainer");
boolean paginate = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:search-iterator:paginate"));
int start = searchContainer.getStart();
int end = searchContainer.getEnd();
int total = searchContainer.getTotal();
List resultRows = searchContainer.getResultRows();
List<String> headerNames = searchContainer.getHeaderNames();
Map orderableHeaders = searchContainer.getOrderableHeaders();
String emptyResultsMessage = searchContainer.getEmptyResultsMessage();
RowChecker rowChecker = searchContainer.getRowChecker();
boolean showpaging = GetterUtil.getBoolean((String)request.getAttribute("showpage"));
if (end > total) {
end = total;
}
if (rowChecker != null) {
if (headerNames != null) {
headerNames.add(0, rowChecker.getAllRowsCheckBox());
}
}
if (resultRows.isEmpty() && (headerNames == null)) {
headerNames = new ArrayList<String>();
headerNames.add(StringPool.BLANK);
}
%>
<c:if test="<%= (resultRows.size() > 0) || ((resultRows.size() == 0) && (emptyResultsMessage != null)) %>">
<div class="results-grid">
<table class="taglib-search-iterator">
<c:if test="<%= (resultRows.size() == 0) && (emptyResultsMessage != null) %>">
<tr class="portlet-section-body results-row">
<td align="center" colspan="<%= headerNames.size() %>">
<%= LanguageUtil.get(pageContext, emptyResultsMessage) %>
</td>
</tr>
</c:if>
<%
boolean allRowsIsChecked = true;
for (int i = 0; i < resultRows.size(); i++) {
ResultRow row = (ResultRow)resultRows.get(i);
String className = "portlet-section-alternate results-row alt";
String classHoverName = "portlet-section-alternate-hover results-row alt hover";
if (MathUtil.isEven(i)) {
className = "portlet-section-body results-row";
classHoverName = "portlet-section-body-hover results-row hover";
}
if (Validator.isNotNull(row.getClassName())) {
className += " " + row.getClassName();
}
if (Validator.isNotNull(row.getClassHoverName())) {
classHoverName += " " + row.getClassHoverName();
}
if (row.isRestricted()) {
className += " restricted";
classHoverName += " restricted";
}
row.setClassName(className);
row.setClassHoverName(classHoverName);
request.setAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW, row);
List entries = row.getEntries();
if (rowChecker != null) {
boolean rowIsChecked = rowChecker.isChecked(row.getObject());
if (!rowIsChecked) {
allRowsIsChecked = false;
}
row.addText(0, rowChecker.getAlign(), rowChecker.getValign(), rowChecker.getColspan(), rowChecker.getRowCheckBox(rowIsChecked, row.getPrimaryKey()));
}
%>
<tr class="<%= className %>"
<c:if test="<%= searchContainer.isHover() %>">
onmouseover="this.className = '<%= classHoverName %>';" onmouseout="this.className = '<%= className %>';"
</c:if>
>
<%
for (int j = 0; j < entries.size(); j++) {
SearchEntry entry = (SearchEntry)entries.get(j);
entry.setIndex(j);
request.setAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW_ENTRY, entry);
%>
<td align="<%= entry.getAlign() %>" class="col-<%= j + 1 %><%= row.isBold() ? " taglib-search-iterator-highlighted" : "" %>" colspan="<%= entry.getColspan() %>" valign="<%= entry.getValign() %>">
<%
entry.print(pageContext);
%>
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
</div>
<c:if test="<%= (resultRows.size() > 10) && paginate %>">
<div class="taglib-search-iterator-page-iterator-bottom">
<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
</div>
</c:if>
<c:if test="<%= (rowChecker != null) && (resultRows.size() > 0) && Validator.isNotNull(rowChecker.getAllRowsId()) && allRowsIsChecked %>">
<script type="text/javascript">
document.<%= rowChecker.getFormName() %>.<%= rowChecker.getAllRowsId() %>.checked = true;
</script>
</c:if>
</c:if>
浙公网安备 33010602011771号