Hi Jay,

So your query returns results but not in the right order?

Create the query first in the Dev > JCR Queries app. It's faster to work with. 
When the query returns the correct results, copy the WHERE clause to your 
stkDownloadList component.

Be careful with quotes! Some properties have colons in their name. The JCR 
Queries app may not require you to surround the property name in quotes but the 
stkDownloadList component does.

Here is an example with assets in the demo-project.

Find all assets that have the string "light" in their title: 
[code]SELECT * FROM mgnl:asset WHERE jcr:path like '/demo-project/%' AND title 
like '%light%'[/code]

Screenshot: [url=http://i.imgur.com/ccEqzL4.png]jcr-queries-app-unsorted[/url]
Screenshot: [url=http://i.imgur.com/6Vpw2lg.png]dialog-unsorted[/url]
Screenshot: [url=http://i.imgur.com/4KWjfcf.png]component-unsorted[/url]

Since there is no ORDER BY clause the assets are returned in the order they 
reside in the JCR hierarchy. This was your original request.

Now sort them alphabetically: 
[code]SELECT * FROM mgnl:asset WHERE jcr:path like '/demo-project/%' AND title 
like '%light%' ORDER BY title ASC[/code]

Screenshot: [url=http://i.imgur.com/rj7Cnaa.png]jcr-queries-app-alpha[/url]
Screenshot: [url=http://i.imgur.com/9FIdHEF.png]dialog-alpha[/url]
Screenshot: [url=http://i.imgur.com/45JDYFp.png]component-alpha[/url]

Note that you don't need the jcr:path condition in the dialog because the 
dialog already has a path field.

To order by other properties you need to know the property name in the JCR. 
Export an asset to XML and look for the property name. For example, to sort by 
date last modified date use the mgnl:lastModified property.

XML export:
[code]
  <sv:property sv:name="mgnl:lastModified" sv:type="Date">
    <sv:value>2009-05-14T13:55:43.808+02:00</sv:value>
  </sv:property>
[/code]

Query in JCR Queries app:
[code]SELECT * FROM mgnl:asset WHERE title like '%light%' ORDER BY 
mgnl:lastModified ASC[/code]

Query in the dialog:
[code]title like '%light%' ORDER BY 'mgnl:lastModified' ASC[/code]


--Antti

-- 
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=551a3707-98cd-4a1d-ae68-85fb21d55a95


----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com>
----------------------------------------------------------------

Reply via email to