AnsweredAssumed Answered

I believe everything you need is already in HEAD.Here's...

Question asked by davidc on Jun 1, 2007
Latest reply on Jul 3, 2007 by davidc
I believe everything you need is already in HEAD.

Here's the full Web Script for displaying the name of the node as specified by its node reference on the url.  Add the following three files to your web scripts folder…

example.get.desc.xml


<webscript>
  <shortname>Search example</shortname>
  <description>Demonstrate use of javascript search api</description>
  <url format="html" template="/showname?noderef={noderef}"/>
  <authentication>user</authentication>
</webscript>

example.get.js


// use the javascript search api to get the node for the noderef argument
var node = search.findNode(args.noderef);

// setup model for template to render
model.node_that_has_been_found = node;

example.get.html.ftl


<html>
  <body>
     <#if node_that_has_been_found?exists>
       Name of node ${args.noderef} is ${node_that_has_been_found.name}.
     <#else>
       Node ${args.noderef} does not exist.
     </#if>
  </body>
</html>

You can then issue the URL…

http://localhost:8080/alfresco/service/showname?noderef=workspace://SpacesStore/cb7c90ec-0dcc-11dc-809c-c38e52448afe

for a node in your repository (use the Node Browser to get a noderef).

Basically, if you add a javascript file, it will be executed before the template.  The full javascript api is available.  You can populate the special 'model' object with named values which are then accessible in the template e.g. node_that_has_been_found in the above example.

Outcomes