%@ page import="com.imcode.imcms.api.*"%>
<%
ContentManagementSystem imcms = ContentManagementSystem.fromRequest( request );
TemplateService templateService = imcms.getTemplateService();
TemplateGroup[] templateGroups = templateService.getAllTemplateGroups() ;
%>
Templates and template groups
All Template groups and theirs templates:
<%
for (int i = 0; i < templateGroups.length; i++) {
TemplateGroup templateGroup = templateGroups[i];
%>- Template group name "<%= templateGroup.getName() %>", id = <%=templateGroup.getId()%>
<%
Template[] templates = templateService.getTemplates( templateGroup);
for (int j = 0; j < templates.length; j++) {
Template template = templates[j];
%>- Template name "<%= template.getName() %>", id = <%=template.getId()%>
<%
}
%>
<%
%>
<%
int templateGroupId = 0;
int templateId = 1;
%>
The template group with id <%= templateGroupId %> has the name "<%= templateService.getTemplateGroupById( templateGroupId ).getName()%>"
The template with id <%= templateId %> has the name "<%= templateService.getTemplateById( templateId ).getName()%>"
<%
String templateName = "demo";
%>
The template with name "<%= templateName %>" has the id <%= templateService.getTemplate( templateName ).getId()%>