Sure.

In my case, I needed all nodes of the type "printServerSite" in a certain folder, so this worked for me (in JSP tags):

<c:set var="queryString" value="/jcr:root/printserver/sites/x-print/ superuser//* order by MetaData/@mgnl:lastmodified descending" /> <cms:query repository="data" query="${queryString}" type="xpath" nodeType="printServerSite" var="sites" />

But of course ordering by MetaData/@mgnl:lastmodified does not make much sense (it works though). Simpler would be:

/jcr:root/printserver/sites/x-print/superuser//* order by @mgnl:lastmodified descending

But since Xpath is pretty powerful I tried some more and came up with this:

/jcr:root/printserver/sites/x-print/superuser//element(*, printServerSite)/MetaData order by @mgnl:lastmodified descending

Here, I'm first filtering for a certain node type then get its MetaData and finally order the MetaData nodes. Same result, more than 4x faster. Now, you could even filter for certain attributes in the node too:

/jcr:root/printserver/sites/x-print//element(*, printServerSite) [...@owner = 'superuser']/MetaData order by @mgnl:lastmodified descending

Xpath _is_ very cool.

-will

On 25.06.2009, at 19:33, Thomas Duffey wrote:



On Jun 25, 2009, at 11:57 AM, Will Scheidegger wrote:

I think I found an other way:

- Don't limit the search to "myDataType" so you'll get the MetaData nodes too.
- sort by @mgnl:lastModified
- only accept "myDataType" nodes in the result

At least this seems to do the trick for me.

Can you share the query you came up with for this?

Tom

On 25.06.2009, at 18:52, Thomas Duffey wrote:



On Jun 25, 2009, at 11:32 AM, Will Scheidegger wrote:

This _should_ be an easy one, but after an hour of trying and googling my content nodes are still not being sorted by their modification date.

My query:

/jcr:root/path/to/data//element(*, myDataType) [...@owner = 'superuser'] order by MetaData/@mgnl:lastmodified

- It does something, because when I leave the order by... away I get a different sort order - But the nodes are definitely not sorted by their modification date.

I struggled with this for a while and ended up getting the unsorted list and then sorting programatically :(



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to