if(templateChild.getParentOrder()!=null && templateChild.getParentOrder() > -1){
List<CategoryVO> parentCategories = newCategoryArticle.getParentCategories();
CategoryVO categoryVO = parentCategories.get(templateChild.getParentOrder());
List<Category> partnerCategory = categoryService.findByParentId(category.getParentId());
newCategoryArticle.setPartner(categoryService.convertToListVo(partnerCategory)); TemplateUtil.convertHtmlAndSave(categoryVO.getPath()+File.separator+templateChild.getEnName(),categoryVO.getViewName(),newCategoryArticle, templateChild);
}else if (templateChild.getParentOrder()!=null && templateChild.getParentOrder().equals(-1)){
CategoryVO parentCategory = newCategoryArticle.getParentCategory();
List<Category> partnerCategory = categoryService.findByParentId(category.getParentId());
newCategoryArticle.setPartner(categoryService.convertToListVo(partnerCategory));
TemplateUtil.convertHtmlAndSave(parentCategory.getPath()+File.separator+templateChild.getEnName(),parentCategory.getViewName(),newCategoryArticle, templateChild);
}else {
TemplateUtil.convertHtmlAndSave(category.getPath()+File.separator+templateChild.getEnName(),newCategoryArticle.getViewName(),newCategoryArticle, templateChild);
}
模板文件下新增文件templates/@CATEGORY_PARTNER_MKDOC.html
点击从文件获取模板
这里主要需要设置parentOrder为0, 详细见上面java代码
模板英文名称是CATEGORY_PARTNER_MKDOC
List<Template> templates = templateService.findByChild(template.getId());
for (Template templateChild : templates){
文章在生成分类页时,也会解析字模板
html/pipline/CATEGORY_PARTNER_MKDOC/202211811130.html