This commit is contained in:
sunxin 2019-03-13 14:13:43 +08:00
parent bd9c950675
commit c0542503f7
2 changed files with 71 additions and 51 deletions

View File

@ -178,7 +178,7 @@ public class SearchAction extends BaseAction {
}
map.put(ParserUtil.COLUMN, column);
//设置栏目编号
map.put(ParserUtil.TYPE_ID, typeId);
// map.put(ParserUtil.TYPE_ID, typeId);
}
// 遍历取字段集合
@ -260,10 +260,12 @@ public class SearchAction extends BaseAction {
page.setPreUrl(preUrl);
page.setLastUrl(lastUrl);
map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(ParserUtil.PAGE, page);
Map<Object, Object> searchMap = new HashMap<>();
searchMap.put(BASIC_TITLE, BasicUtil.getString(BASIC_TITLE));
searchMap.put(ParserUtil.PAGE_NO, pageNo);
map.put(SEARCH, searchMap);
map.put(ParserUtil.PAGE, page);
//动态解析
map.put(ParserUtil.IS_DO,false);
//设置动态请求的模块路径

View File

@ -82,7 +82,6 @@ public class CmsParserUtil extends ParserUtil {
StringWriter writer = new StringWriter();
try {
// 为了分页添加column,判断栏目是否为父栏目
template.process(null, writer);
String content = writer.toString();
//获取列表页显示的文章数量
@ -99,13 +98,12 @@ public class CmsParserUtil extends ParserUtil {
contentModel = (ContentModelEntity) SpringUtil.getBean(IContentModelBiz.class).getEntity(columnContentModelId);
}
int pageNo = 1;
// 遍历分页
for (int i = 0; i < totalPageSize; i++) {
PageBean page = new PageBean();
page.setSize(pageSize);
//全局参数设置
Map parserParams = new HashMap();
parserParams.put(COLUMN, column);
page.setTotal(totalPageSize);
//parserParams.put(TYPE_ID, column.getCategoryId());
parserParams.put(IS_DO, false);
parserParams.put(HTML, HTML);
if (contentModel!=null) {
@ -116,6 +114,30 @@ public class CmsParserUtil extends ParserUtil {
if(ParserUtil.IS_SINGLE) {
parserParams.put(ParserUtil.URL, BasicUtil.getUrl());
}
//文章列表页没有写文章列表标签总数为0
if (totalPageSize <= 0) {
// 数据库中第一页是从开始0*size
// 首页路径index.html
mobilePath = ParserUtil.buildMobileHtmlPath(column.getColumnPath() + File.separator + ParserUtil.INDEX);
columnListPath = ParserUtil.buildHtmlPath(column.getColumnPath() + File.separator + ParserUtil.INDEX);
// 设置分页的起始位置
page.setPageNo(pageNo);
parserParams.put(ParserUtil.PAGE, page);
TagParser tag = new TagParser(content,parserParams);
FileUtil.writeString(tag.rendering(), columnListPath, Const.UTF8);
// 判断是手机端生成还是pc端,防止重复生成
if (ParserUtil.hasMobileFile(column.getColumnListUrl())) {
writer = new StringWriter();
mobileTemplate.process(null, writer);
tag = new TagParser(writer.toString(), parserParams);
// 将tag.getContent()写入路径
FileUtil.writeString(tag.rendering(), mobilePath, Const.UTF8);
}
writer = new StringWriter();
} else {
// 遍历分页
for (int i = 0; i < totalPageSize; i++) {
if (i == 0) {
// 数据库中第一页是从开始0*size
// 首页路径index.html
@ -130,14 +152,11 @@ public class CmsParserUtil extends ParserUtil {
columnListPath = ParserUtil
.buildHtmlPath(column.getColumnPath() + File.separator + ParserUtil.PAGE_LIST + pageNo);
}
// 设置分页的起始位置
page.setPageNo(pageNo);
parserParams.put(ParserUtil.PAGE, page);
TagParser tag = new TagParser(content,parserParams);
FileUtil.writeString(tag.rendering(), columnListPath, Const.UTF8);
// 判断是手机端生成还是pc端,防止重复生成
if (ParserUtil.hasMobileFile(column.getColumnListUrl())) {
writer = new StringWriter();
@ -146,11 +165,10 @@ public class CmsParserUtil extends ParserUtil {
// 将tag.getContent()写入路径
FileUtil.writeString(tag.rendering(), mobilePath, Const.UTF8);
}
writer = new StringWriter();
pageNo++;
}
}
} catch (TemplateException e) {
e.printStackTrace();
}