AnsweredAssumed Answered

Simple userhome Web Script

Question asked by mmoghadas on Mar 26, 2008
Latest reply on Apr 8, 2008 by rivetlogic
Hi-  I'm trying to modify this simple script to show userhome (when logged in) instead Company Home.  The result should be:

/Company Home/User Homes/<username>

When I change myfile1 variable in userfolder.get.js

from:   var myfiles1 = roothome.childByNamePath(url.extension);

to:  var myfiles1 = userhome;

I can see the user's files and directories, but clickin does't take me anywhere. 

Here are the script files.  Any help is appreciated and Thank you.


===========================================================
userfolder.get.desc.xml
===========================================================
<webscript>
  <shortname>Folder Listing Sample</shortname>
  <description>Sample demonstrating the listing of folder contents</description>
  <url>/myfiles/{path}</url>
  <format default="html">argument</format>
  <authentication>guest</authentication>
  <transaction>required</transaction>
</webscript>


===========================================================
userfolder.get.html.ftl
===========================================================
<html>
  <head>
    <title>${myfiles1.displayPath}/${myfiles1.name}</title>   
   <link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">   
  </head>
  <body>

   
   
    <br>      
    Folder: ${myfiles1.displayPath}/${myfiles1.name}
    <br>   
   
    <table>
     <tr>
    <td>
    <br>
<h1>Folders</h1>

<ul>
<#list myfiles1.children as child>
   <#if child.isContainer>
     <li><img src="/alfresco${child.icon16}" alt="myfiles1"> <a href="${url.serviceContext}/myfiles<@encodepath node=child/>" title="Browse to ${child.name}">${child.name}</a></li>
  </#if>
</#list>
</ul>

<h1>Documents</h1>
<ul>
<#list myfiles1.children as child>
   <#if child.isDocument>
    <li>
      <img src="/alfresco${child.icon16}" alt="myfiles1"> <a href="${url.serviceContext}/api/node/content/${child.nodeRef.storeRef.protocol}/${child.nodeRef.storeRef.identifier}/${child.nodeRef.id}/${child.name?url}">${child.name}</a>
    </li>
  </#if>
</#list>
</ul>
   
    </td>
     </tr>
    </table>
   

   
   
   
<br>
   
   
      <table>
     <form action="${url.service}" method="post" enctype="multipart/form-data" accept-charset="utf-8">
       <tr><td>File:<td><input type="file" name="file">
       <tr><td>Title:<td><input name="title">
       <tr><td>Description:<td><input name="desc">
       <tr><td><td>
       <tr><td><td><input type="submit" name="submit" value="Upload">
     </form>
   </table>
   
  </body>
</html>

<#macro encodepath node><#if node.parent?exists><@encodepath node=node.parent/>/${node.name?url}</#if></#macro>


===========================================================
userfolder.get.js
===========================================================
// locate folder by path
// NOTE: only supports path beneath company home, not from root
var myfiles1 = roothome.childByNamePath(url.extension);
if (myfiles1 == undefined || !myfiles1.isContainer)
{
      status.code = 404;
   status.message = "myfiles1 " + url.extension + " not found.";
   status.redirect = true;
}
model.myfiles1 = myfiles1;

Outcomes