get the name of the global template

Hi

Is there any way in velocity you can get the name of the global template that the local template is using? I want to be able to hide certain fields based on the global template without having to create another global template.

We’re using Version: 6.5.0
Build id: 200705R01 (3210)

Cheers
James

The short answer is that there isn’t any easy way to get the name of the global. You can get the guid of the global from $sys.assemblyItem.Template.GlobalTemplate. If you do something like this:

$globalGuid = $sys.assemblyItem.Template.GlobalTemplate
$globalGuidStr = if ($globalGuid != null) { $globalGuid.toString(); } else { null; }

(where = is my way of separating the variable and binding in the bindings editor.) You could conceivably then compare $globalGuidStr with the guid of the global template in question.

Note that since we are not yet using actual GUIDs for templates for backward compatibility reasons, you will likely need to fix up such a literal reference when moving from dev to production.

You should also note that it’s a simple matter to write a JEXL function to return the name of the template based on the GUID. Just call the Assembly Service: IPSAssemblyService.loadTemplate() will return the IPSAssemblyTemplate, from which you can call getName().

This does require writing a small amount of Java code, however.