cancel
Showing results for 
Search instead for 
Did you mean: 

Simple userhome Web Script

mmoghadas
Champ in-the-making
Champ in-the-making
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;
3 REPLIES 3

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

You have to implement the functionality. Pass the argument and query the folder to display the results.
Take a look at Myspaces  Webscript.



Best Regards,
Shagul

mmoghadas
Champ in-the-making
Champ in-the-making
Hi Shagul-  Where do I find this Myspaces Webscript?

rivetlogic
Champ on-the-rise
Champ on-the-rise
You should be able to access the webscript  using.
http://ipaddressSmiley Tongueort/alfresco/service/ui/myspaces

Also you should be able to locate the script from the index using
http://ipaddressSmiley Tongueort/alfresco/service/index/all

All descriptions and javascripts can be found in the classpath under
classpath:/alfresco/templates/webscripts/org/alfresco/portlets/


Best Regards,
Shagul