AnsweredAssumed Answered

better performing template queries? (for better recent docs)

Question asked by stk137 on Aug 23, 2007
Latest reply on Jan 17, 2008 by kevinr
So I am trying to create a better recent docs template.
One that has the last 15 most recently modified docs displayed in descendending order by date.  I also separate out forum posts from other content so I can display them differently.  Part of my current template is below.

The problem seems to be that this performs terribly (when there's more than handful of docs).  How can I make it perform much better?
AFAIK using lucene with search parameters is not an option in a template.  So am I stuck having to do the sorting and limiting in template script?
When you do something like this, it's not pulling back the content in the search results that I am sorting, is it?  Only meta-data right?

BTW (if it's not already requested) I'd like to be able to use lucene with search params in scripting and templating.

thx

        <#– recent docs –>
        <h2 style="margin-bottom:0.2em;">Most Recently Modified Docs</h2>
        <table cellpadding=2>
   
           <tr>
              <td></td>
              <td><b>Name</b></td>
              <td><b>Location</b></td>
              <td><b>Date</b></td>
           </tr>
           <#list space.childrenByXPath[".//*[subtypeOf('cm:content') and not(subtypeOf('fm:post'))]"]?sort_by(['properties','cm:modified'])?reverse as child>
              <#if child_index = 15><#break></#if>
                 <tr>
                    <td><a href="/alfresco${child.url}" target="new"><img src="/alfresco${child.icon16}" border=0></a></td>
                    <td><a href="/alfresco${child.url}" target="new">${child.properties.name}</a></td>
                    <td><a href="/alfresco${child.parent.url}" target="new">${child.displayPath?replace(fullSpacePath,".")}</a></td>
                    <td>${child.properties["cm:modified"]?datetime}</td>
                 </tr>
           </#list>
        </table>
              
<#– Recent Topics/Posts –>
        <#assign recentPosts=space.childrenByXPath[".//*[subtypeOf('fm:post')]"]?sort_by(['properties','cm:modified'])?reverse>
        <#if (recentPosts?size > 0) >
        <h2 style="margin-bottom:0.2em;">Most Recent Topics/Posts</h2>
                <table cellpadding=2>
                   <tr>
                      <td></td>
                      <td><b>Topic/Post</b></td>
                      <td><b>Date/Author</b></td>
                   </tr>
                   <#list recentPosts as child>
                      <#if child_index = 8><#break></#if>
                         <tr>
                            <td valign="top"><a href="/alfresco${child.parent.url}"><img src="/alfresco${child.parent.icon16}" border=0></a></td>
                            <td valign="top"><a href="/alfresco${child.parent.url}">${child.parent.properties.name}</a><br/>
                            <#– <a href="/alfresco${child.url}" target="new">${child.properties.name}</a><br/> –>
                            <#if child.content?length < 40>
                                <a style="font-size:.9em;" href="/alfresco${child.url}" target="new">${child.content?replace("<br/>","- ")}</a><br/>
                            <#else>
                                <a style="font-size:.9em;" href="/alfresco${child.url}" target="new">${child.content?substring(0,40)?replace("<br/>","- ")}…</a><br/>
                            </#if>
                           
                            </td>
                            <td valign="top">${child.properties["cm:modified"]?datetime}<br/>
                                <span style="font-size:.9em;">${child.properties["cm:modifier"]}</span>
                            </td>
                         </tr>
                   </#list>
                </table>
   
        </#if>

Outcomes