首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在以编程方式创建期刊文章时添加结构和模板

问如何在以编程方式创建期刊文章时添加结构和模板
EN

Stack Overflow用户
提问于 2016-03-29 05:13:27
回答 2查看 1.9K关注 0票数 3

我已经通过门户UI创建了结构和模板。现在,我正在以编程方式在action类中创建日志文章。在操作类中创建日志文章时,我希望将现有的结构和模板设置为此日志文章。我试图使用以下方法,但这里指的是ddmStructureKey和ddmTemplateKey。

这些是否只与我的要求有关?

代码语言:javascript
复制
JournalArticleLocalServiceUtil.addArticle(userId, groupId, folderId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, serviceContext)

帮我解决这件未知的事情。谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-29 10:41:42

下面的代码是我为回答上述问题而编写的,它适用于me.Thanks到@Romeo。根据您的要求,我已经对一些things.As进行了硬编码,您可以做任何您想做的事情。

代码语言:javascript
复制
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
                Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
                DDMStructure ddmStructure=DDMStructureLocalServiceUtil.getDDMStructure(11515);
                DDMTemplate ddmTemplate=DDMTemplateLocalServiceUtil.getDDMTemplate(11517);
                Map<Locale,String> titleMap=new HashMap<Locale,String>();
                titleMap.put(themeDisplay.getLocale(), "First Record");
                String content=
                        "<root available-locales='en_US' default-locale='en_US'>"
                                +"<dynamic-element dataType='string' indexType='keyword' name='Title' readOnly='false' repeatable='false' required='false' showLabel='true' type='text' width='small'>"
                                    +"<dynamic-content>FirstRecord</dynamic-content>"
                                +"</dynamic-element>"
                                +"<dynamic-element dataType='string' indexType='keyword' name='Description' readOnly='false' repeatable='false' required='false' showLabel='true' type='textarea' width='small'>"
                                +"  <dynamic-content>This the first one doing by programatically</dynamic-content>"
                                +"</dynamic-element>"
                                +"<dynamic-element dataType='image' fieldNamespace='wcm' indexType='keyword' name='DamImage' readOnly='false' repeatable='false' required='false' showLabel='true' type='wcm-image' width=''>"
                                +"  <dynamic-content>http://localhost:8080/documents/10184/0/welcome_community/0dc0adb1-b565-409a-b766-96d1e42b04fb?t=1459163274526</dynamic-content>"
                                +"</dynamic-element>"
                                +"<dynamic-element dataType='string' indexType='keyword' name='UserIdExcel' readOnly='false' repeatable='false' required='false' showLabel='true' type='text' width='small'>"
                                +"  <dynamic-content>458155</dynamic-content>"
                                +"</dynamic-element>"
                                +"<dynamic-element dataType='string' indexType='keyword' name='Username' readOnly='false' repeatable='false' required='false' showLabel='true' type='text' width='small'>"
                                +"  <dynamic-content>LaxmanDeepak</dynamic-content>"
                                +"</dynamic-element>"
                                +"<dynamic-element dataType='date' fieldNamespace='ddm' indexType='keyword' name='DateFromExcel' readOnly='false' repeatable='false' required='false' showLabel='true' type='ddm-date' width='small'>"
                                +"<dynamic-content>03/29/2016</dynamic-content>"
                                +"</dynamic-element>"
                            +"</root>";
                ServiceContext serviceContext = new ServiceContext();
                serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
                serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

                JournalArticleLocalServiceUtil.addArticle(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), parentFolderId, titleMap, null, content, ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), serviceContext);
票数 2
EN

Stack Overflow用户

发布于 2016-03-29 08:43:19

ddmStructure和ddmTemplateKey是文章的结构,以及呈现该文章的模板(速度、共济会)。如果使用空字符串,则选择默认模板和默认结构,否则,如果不使用结构和模板,则必须使用这些服务来获取它们。

代码语言:javascript
复制
DDMStructureLocalServiceUtil
DDMTemplateLocalServiceUtil
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36275950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档