开发者

Alfresco unordered list web script

I need to build an unordered list starting from an Alfresco Space:

I found this working template:

 <开发者_运维知识库;#macro recurse_macro node depth>
  <#if node.isContainer>
    <tr>
 <td align='left'>(${depth}) 
    <#if (depth>0) >
   <#list 1..depth as i>.</#list> 
    </#if>
  <img src="/alfresco${node.icon16}"> <a href="/alfresco${node.url}">${node.properties.name}</a>
 </td>
  </tr>

   <#list node.children as child>
 <#if child.isContainer && node.children?size != 0 >
   <@recurse_macro node=child depth=depth+1/>
 </#if>
   </#list>
  </#if>
</#macro>

<b>Recursive Listing of Spaces:</b>
<table border="1" celpadding="1" cellspacing="1">
<tr><th> Name Space </th></tr>
<@recurse_macro node=companyhome depth=0/>
</table>

What I need is to modify this template to render the space content as un unordered list:

<ul id="0" >
    <li id="1">Content_one
    <ul>
       <li id="2">Content_two
    <ul>
   <li id="3">Content_three</li>
      <li id="4">Content_four</li>
     </ul>
       </li>
       <li id="5">Content_five</li>
    </ul>
    </li> 
</ul>

Any help will be appreciated.

Thanks


Well, you need to add a < li> tag everywhere where you list a node, for one: First replace the table tags with < ul id=0> and < /ul>.

Then, in the #macro - you need to list the content name but without the < td> part. so delete the < td> and < /td> tags. Also, you don't need the dots, so remove the <#if (depth>0) > block.

You need a counter. So have an <#assign counter = 0/> just before you enter the recurse macro for the first time.And increment the counter every time you enter the macro (so on line two of the macro: <#assign counter = counter+1/>

You also need < li> tags around the line where your actual document name is. So enclose the < img /> and < a> < /a> blocks in a < li id="${counter}"> and close it with < /li>

Now, you will also need a new set of < ul> tags when you do a recurse. To do it, you need to change the <

#if child.isContainer && node.children?size != 0 >
   <@recurse_macro node=child depth=depth+1/>
 </#if>

block. Enclose the tag with your < ul> and < /ul> tags.

That should do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜