jerem wrote:
Hello,
I created a FAQ application, pretty much like the template, but with an
added "Category" field.
This "Category" is stored in a DBTreeList property, and contains classified
categories, sub-categories, sub-sub categories ...
When in the context of an FAQ object, this list displays well, and lets the
user choose to which category belongs the FAQ entry.
To build the "WebHome" for this FAQ, I would like to give users opportunity
to filter FAQ entries depending on this same Category. To do so, IMO what
would be logical would be to display this same field based on property
"Category", in edit mode (to have the drop-down list), but here there is no
contextual object.
Is there a way to do this easily ? I workarounded it by creating a fake
object in my WebHome with same property definition as "Category", but then
if I want to keep track of what is selected the object value has to be
updated each time the user filters the view, and it will be updated for
everyone, I think it's a quite ugly solution and I'm looking for something
better ...
I think this subject might already have been discussed, but could not find
anything in the mailing-list,
I don't remember anything on this topic.
A quick suggestion:
- Don't use a real object, instead dynamically create one using
scripting, without saving it (#set($o = $doc.newObject('Your.Class'))
- To remember selected options between requests, put the object in the
URL, or in a form
- To reload the state from the request, use
$doc.updateObjectFromRequest('Your.Class'). This method automatically
creates a new object if one doesn't exist, so you don't even have to
call newObject. Just use:
#set($o = $doc.updateObjectFromRequest('Your.Class'))
--
Sergiu Dumitriu
http://purl.org/net/sergiu/