It's possible the auto tag-creation when a template is used?

cancel
Showing results for 
Search instead for 
Did you mean: 
aladme
Member II

It's possible the auto tag-creation when a template is used?

Hi all,

I want to create a template folder for the new client site. It will create a folder foreach client with some content.

Can I force that everything under the new created client folder will be tagged with the client name (folder name)??
So for that I should have a process which creates a tag with the client name when the template is used.

It could be nice if someone can direct me on the right direcction.

Thanks! 

1 Reply
mehe
Senior Member II

Re: It's possible the auto tag-creation when a template is used?

Hi,

you could add a rule to your folder template, that executes a Javascript and fires on "create or moved" (I think) on the folder and all sub folders. But a Customer name is probably hard to transfer in a tag (imagine "ACME Co. Inc. and Sons"). Rules are also included by creating a folder from a template.

You should better create a custom document model, which is easy in community >=5.1 because of the  admin tools/model manager. Create, for example, a customerData aspect, which holds every standard-metadata-field that should be applied to your documents in the customer folder. Then, add an "add aspect" rule to your template which simply adds this aspect to the documents created in the folder...

But for your tagging example, you would need a "rule script" like

if (document.isDocument) {
  document.addAspect("cm:taggable");
  document.addTag(space.name);
‍‍};‍‍‍‍

that is applied to all subfolders and adds the tag to every document created or moved to your folder. But beware, this is "quick and dirty", because the name of your space folder may not be ideal for a tag-name and could throw an error that prevents you from adding documents to your folder. If your structure is only one level deep (no more subfolders under the customer folder) you could use "parent" instead of "space" in the above script.