saurabh
I'm new here

i want to display all the formet template that i am using in module

Hi,

I want to display all the formet template that starts from "ft_" . i did lot of changes but could't get formet template list.

I am able to get all page template ("pt_"), section template (st_ ) except formet template (ft_)

TemplateStoreRoot  templateStoreRoot=(TemplateStoreRoot) project_name.getUserService().getStore(Type.TEMPLATESTORE,false),

Listable<Template> listable=templateStoreRoot.getChildren(Template.class,true);

for(Template template : listable)

{

   if(template.getUID().startsWith("ft_"))

   {

     System.out.println(template.getUid());

   }

}

Please assist me what change i can make to get all the formet template for a given project (project_name)

Thanks.

8 Replies
aVogt
Returning Creator

I use this:

ts = us.getStore(de.espirit.firstspirit.access.store.Store.Type.TEMPLATESTORE, false);

FormatTemplates fts = ts.getFormatTemplates();

Class templateClassName = java.lang.Class.forName("de.espirit.firstspirit.access.store.templatestore.FormatTemplate");

listable = fts.getChildren(templateClassName, true);

Andreas

Thanks Andreas for answer.

but my requirement is i want to collect first all the template(page, section,formet,datasource etc) from template store root and store in a list and then want to apply other logic by iterating each template if they are formet template do something else something.

0 Kudos

I've implemented something similar once:

map = new HashMap();

map.put("PageTemplate", PageTemplate.class);

map.put("SectionTemplate", SectionTemplate.class);

map.put("FormatTemplate", FormatTemplate.class);

map.put("LinkTemplate", LinkTemplate.class);

map.put("Script", Script.class);

map.put("Schema", Schema.class);

map.put("Workflow", Workflow.class);

set = map.keySet();

for (s : set) {

      print("CHECKING TEMPLATES OF: " + s);

      print("-----------");

      templates = store.getChildren(map.get(s), true);

      for (tpl : templates) {

           print(tpl.getName());

     }

}

Syntax Highlighting ergänzt

0 Kudos

Hello Saurabh,

do you need further help or did the given answers already help you? If so, it would be great if you mark the "correct answer".

If you meanwhile found a solution by yourself, it would be very kind of you if you post it here.

Best regards

Michaela

0 Kudos
vijay1v
I'm new here

Hi Saurabh

list = context.requireSpecialist(StoreAgent.TYPE).getStore(Store.Type.TEMPLATESTORE).getChildren(de.espirit.firstspirit.access.store.templatestore.FormatTemplate.class, true).toList() will get you all the format templates.

Regards

Vijay

0 Kudos

Hi Vijay,

toList is not recommended, since it can cause performance issues!

You can still iterate without the toList call though.

Kind regards

Julius

I tried "getChildren(de.espirit.firstspirit.store.access.sitestore.PageRefImpl)" but it didn't work. Previously I iterated it without any parameter at all and the classname of one of the elements of the result list had exactly this classname (I copied it from there). But no results.

0 Kudos

Hi Stefan,

sounds strange. The getChildren Method can be called on any Store, but passing PageRef doesn't make any sense when you're in the TemplateStore. TemplateStore can only return a template from the package "de.espirit.firstspirit.access.store.templatestore.*".

PageRef will work when you're using the SiteStore.

Also you shouldn't use "PageRefImpl" as it is not a part of the official FirstSpirit Access API. So you should basically use Classes/Interfaces from the package "de.espirit.firstspirit.access.*". In this case you would pass just the PageRef Interface instead of the PageRefImpl Class.

Kind regards

Julius

0 Kudos