Hi Anja

See my answers below. They are a little short, because I am on my way out, but I thought "better a short answer than no answer".

Cheers
Giancarlo

On Aug 15, 2007, at 12:51 AM, Anja Maass wrote:

Giancarlo Berner schrieb:
Hi Anja

It depends what your understanding of "sort" is. Typically we sort pages among the same "hierarchy", e.g. if you have a couple of child pages below the same parent page, then you can "order" them. The repository has a hierarchical structure, so we do not really have something like a "sort".

However, what you see very often, is that you do a search (e.g. for a date structure) and then sort the result set. This can by adding a sort order to the search or by iterating through the resultset, adding e.g. handle and date to a list object and then sort.

You though also want to consider the beauty of the hierarchical structure. You mentioned earlier you have the date in the page title. But you could also look into different scenarios. One I have used for news archives: I create a page with the handle representing the year (e.g. /dms/news/2006), there I have child pages for the months, (e.g. /dms/news/2006/05). And all articles added have either a day/time type of handle or a news-descriptive handle and a "issue date" property. So when I add a new article, I have a small script creating the correct path and storing the article. This way I can select a date and easily find all articles for the year, year/month or even year/month/day.

Another idea is not to use the page title for your date, but add a new property (e.g. in the page porperties or a specific paragraph). Your search would look for a date value within that property. This way the title is "free" for a more informative usage.

hth
Giancarlo


On Aug 14, 2007, at 6:35 AM, Anja Maass wrote:

Hi,

I hope you can help

Ho can I sort my pages by a date?
For example I search after pages with the string "Mai" in the title,now I want to display all hits sorted by date. Is there any taglib already avialbale.

Thanks for any hint.

Anja


----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------



----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------

Hi Giancarlo ,
thanks for your detailed answer.
But I have still one or two questions..

"It depends what your understanding of "sort" is. Typically we sort pages among the same "hierarchy", e.g. if you have a couple of child pages below the same parent page, then you can "order" them. The repository has a hierarchical structure, so we do not really have something like a "sort". "

How can I order my child pages below a parent page...
The simplest way is of course in the AdminCentral. Click on the left side Website menu to get the children of a page in the right-side pane. Then you can just drag and drop the pages. I assume though that you are trying to display the children pages in a given order. This means, that you first instantiate a "Content" object based on the parent page. Then you can use the method "getChildren(Content.ContentFilter filter, java.util.Comparator orderCriteria)" to get a Java Collection object containing the children pages in the order you specify with the Java Comparator. I recommend that you download the Magnolia Javadoc from documentation.magnolia.info and check out the "Content" class.



"Another idea is not to use the page title for your date, but add a new property (e.g. in the page porperties or a specific paragraph). Your search would look for a date value within that property. This way the title is "free" for a more informative usage. " Yes,*now we have a new property added in a specific paragraph*...But how can we search for a date value withih that property? Can we use the searchResultSnippet tag for it?
I don't remember if the "searchResultSnippet" tag just does a fulltext search on a given search term. However, I recommend that you use the "QueryManager" to build the search. You can use a SQL like search statement, e.g. "SELECT * FROM mgnl:content LOCATION "/ myParent/myNews/* WHERE {propertyname} LIKE "2007%" ORDER BY propertyname". In the FROM clause you have the nodetype (e.g. * or mgnl:content or whatever nodetype you want), the LOCATION clause specifies which handles to search and the WHERE clause can be used to search properties. I recommend you download the JSR 170 specs from jcp.org/en/jsr/detail? id=170. There is a detailed description about the search term. And btw: you can also use XPath to search.

How can I add a search order to a search? *Could you specify what you mean with "adding handle and a date to list object and then sort" ? *
On a second thought it's not such a good idea :-) I was thinking of iterating through the child pages, creating a Java List object with some values and using the Collection.sort() method to sort them to whatever order you want to represent. This I use when I have specific properties/values I want to check (e.g. "showInNavigation", an expired date, etc. If it's a search, then follow above.

I don't know how I can sort my results after searching by a specify property
Use the JCRQL language as described above (or XPath).

Sorry,but we are very unversed with searching for pages and sort of pages...
No problem!

Many thanks for a reply......

Anja







----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------



----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------

Reply via email to