cancel
Showing results for 
Search instead for 
Did you mean: 

Call Scripts from Template

emmy
Champ in-the-making
Champ in-the-making
Hi,
I want call to function scripts created in Company Home/Data Dictionary/Scripts/remove-content.js from template in this way:


<table cellpadding="2" cellspacing="2" border="0" width="100%" style="font-size: x-small;">
   <#list companyhome.childrenByLuceneSearch[searchString] as child>
        <tr>
        <td><a href="/alfresco${child.url}">${child.properties.name}</a></td>
        <td><img src="/alfresco/images/icons/delete.gif" border="0" onClick="removeNode(${child.properties.name})"></td>


where removeNode is the function script created.

Is it possible? How?

Regards,
Emanuela
4 REPLIES 4

kevinr
Star Contributor
Star Contributor
It is not possible to execute scripts from within templates. It is something we might look at in the future.

Thanks,

Kevin

ajshaw
Champ in-the-making
Champ in-the-making
You could try this:

What i am currently doing to resolve this is to fire up the script from a popup window:

function update() {
window.open('/alfresco/command/script/execute/workspace/SpacesStore/0543b4be-0776-11db-80d6-ad41b73bdc30/workspace/SpacesStore/${document.id}?LFL='+LFL+'&LFI='+LFI);
}

I make this window as small as possible and appear offscreen so it is invisible.

Then when the script has finished, the html it returns is a blank page with an onload="window.close();

as far as the end user is aware, the script is executed from the template.

When i'm finished, i'll adjust it to use ajax so that i don't have to use the popup window hack.


Aaron.

kevinr
Star Contributor
Star Contributor
That's quite nifty - but there is an issue that the script will be executed in a separate transaction to the template. So any changes you make to nodes that you have already accessed in the template model may not be reflected as you think - so be careful using this trick Smiley Happy

Thanks,

Kevin

ajshaw
Champ in-the-making
Champ in-the-making
Ahh. Sneaky. Ok, Thanks.

Whoa. Old thread. How time flies.