An enhancement that I made to the default Main.AllDocs page illustrates
how to do what you ask, which is to modify the sorting order of items.
It's done by composing a modification to the SQL string passed to
xwiki.searchDocuments(). There is, to the best of my knowledge, no
documentation on how exactly this string affects the database query
inside the search, but generally it looks like it gets parsed into
clauses that are inserted and/or merged into the default query at
syntactically appropriate places. In your case, a simple "order by"
clause would appear to be all that's needed, and of course if the status
field doesn't sort in the order you want it to appear in, you have to
give them sequence numbers or something similar.
The "order by" field is passed to the doc by a parameter named "ordby",
and the page provides links that invoke it with popular values.
By the way, I do have a project management page that does something very
similar, with a table of projects containing links to plan documents and
status, priority and other fields, plus a link to a status page that
sucks journal entries from the plan docs, displaying the same table but
with internal links to the latest journal entries for that project.
I've been intending to add the ordering feature to it, but since it's in
the bells-and-whistles category from my boss's point of view, I haven't
got to that. Of course, you are probably not doing the
xwiki.searchDocuments (although that's certainly one way of doing it),
but I believe there's a similar facility in the doc.getObjects method.
----------------------------------------------------------
#set ($ordby = $request.getParameter("ordby")) ##
#if (!$ordby)
#set ($ordby = "doc.web, doc.name")
#end
#set ($sql = "$where order by $ordby")
1 All Documents of this Wiki
Order by:
[Document Name>$doc.fullName?ordby=doc.web,doc.name]
[Creator>$doc.fullName?ordby=doc.creator]
[Last Author>$doc.fullName?ordby=doc.author]
[Date>$doc.fullName?ordby=doc.date desc]
#foreach ($item in $xwiki.searchDocuments($sql))
## display each item, keeping track of the status and displaying it
when it's different
#end
------------------------------------------------------------
brain[sic]
-----Original Message-----
From: jjanssen(a)nl.swets.com [mailto:jjanssen@nl.swets.com]
Sent: Tuesday, March 14, 2006 12:14 AM
To: xwiki-users(a)objectweb.org
Subject: [xwiki-users] Sorted object list
Hello,
I've got a generic question. In my wiki I'm using many sorted lists. But
there must be a smarter way of creating these lists then what I'm doing
now. Currently I'm doing the following:
Form 1 used to fill out object of type Project, with several attributes
such as the project name and status. On a overview page I want to order
the projects by name based on their status. This will create something
like:
- active:
- project1
- project4
- closed:
- project2
- project5
- deprecated:
- project3
In which all the projects are links to the pages of the projects,
containing all the project information.
Has anybody any idea of a smart way of doing this. Currently I'm looping
through all project objects for every possible status. This is way too
much overhead.
Thanks,
Joep
Hello,
I've got a generic question. In my wiki I'm using many sorted lists. But there must be a smarter way of creating these lists then what I'm doing now. Currently I'm doing the following:
Form 1 used to fill out object of type Project, with several attributes such as the project name and status. On a overview page I want to order the projects by name based on their status. This will create something like:
- active:
- project1
- project4
- closed:
- project2
- project5
- deprecated:
- project3
In which all the projects are links to the pages of the projects, containing all the project information.
Has anybody any idea of a smart way of doing this. Currently I'm looping through all project objects for every possible status. This is way too much overhead.
Thanks,
Joep
Thanks. I'm still baffled, and this is another solution that requires
programmer access to the wiki, but at this point, some solution is
better than no solution. I've even considered throwing in some
JavaScript code to do it.
It has been suggested by a co-worker that the java.util.Calendar class
has the date arithmetic needed, but I don't know how to instantiate a
class that isn't part of, or returned from a method on, an XWiki object,
and I don't see any that do that.
brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 10, 2006 7:01 PM
To: xwiki-users(a)objectweb.org
Subject: Re: [xwiki-users] Dates (was: Long arithmetic...?)
Typical. I missed a brace off the if statement.
Sorry if you just cut and pasted the wrong answer.
Cheers,
Mark.
CORRECTION BELOW
Hi Brian.
I am not sure about with Velocity but you should be able to do this
easily with a Groovy script.
It basically is Java without the braces and type declarations so it is
very powerful. Apologies if I have it wrong below but I have only
started playing with it a few days ago.
Try something like this below in your page.
<%
def today = new Date()
println today
if(testitem < (today - 7))
{
println "This is more than a week old"
}
else
{
println "This is less than a week old"
}
%>
If someone who knows Groovy well can correct that for you it might be a
solution.
Hope it helps.
Cheers,
Mark
On 11 Mar 2006, at 1:19 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
It troubles me that no one has had an answer to this so far.
I tried asking roughly the same question of the velocity-users list and
was told that a new version of Velocity now does arithmetic with
non-integer numbers, but two things make that problematic: first, I
have limited access to the server to install software; second, I can't
believe that no one in all of XWiki's lifetime has ever tried to do any
date calculations, such as the difference of two dates, or
adding/subtracting intervals.
Isn't there an easier way to do this? All I want to do is decide
whether something's a week old.
brain[sic]
-----Original Message-----
From: THOMAS, BRIAN M (SBCSI)
Sent: Friday, March 03, 2006 5:18 PM
To: xwiki-users(a)objectweb.org
Subject: [xwiki-users] Long arithmetic...?
It seems that a Velocity #set directive fails when the RHS involves any
arithmetic operation with long integers.
Specifically, I just wanted to determine the difference between two
dates, thus:
#set ($age = $xwiki.currentDate.time -
$obj.xWikiObject.getDateValue("donedate").time)
I confirmed that I got credible results from both of the operands by
printing them, and I could assign either of them to another variable
name, but setting $age to the result of any arithmetic operation with
any of them always gave "$age" as the formatted result.
This shouldn't be this hard, should it?
brain[sic]
--
You receive this message as a subscriber of the
xwiki-users(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Hi,
I've been working mostly on an individual xwiki installation until
now, and just started playing with the free hosted virtual wiki
service on wiki.com - it's very cool. :)
However, I'm trying to attach some small image files (<20k) to my
wikis, and the attachments disappear shortly after seemingly attaching
correctly. I do not get any error messages or warnings - the
attachments just go away.
Could this be related to the maintenance that occurred this weekend?
Or perhaps is there an attachment restriction on the free wikis?
The wikis are loa.xwiki.com and openmpt.xwiki.com.
Regards,
Robin.