Hello, I don't know if it's really what you need, but here is a snippet that dumps all documents, their classes, and objects, for all documents in a space : {{velocity}} #set($hql = "where doc.space='Custom' order by doc.name asc") #set($results = $xwiki.searchDocuments($hql, 0, 0)) #foreach ($item in $results) #set($itemdoc=$xwiki.getDocument($item)) Document : $itemdoc.name #set($itemclasses=$itemdoc.getxWikiClasses()) #foreach ($class in $itemclasses) Class : $class.name #set($objects=$itemdoc.getObjects($class.name)) #foreach ($obj in $objects) Object : $obj.number #foreach ($prop in $obj.propertyNames) $prop #end #end #end #end {{/velocity}} If I understand well, in your case you might want to filter XWiki.TagClass wich appear for all documents, and restrict to custom classes. Hope this helps, Jeremie 2010/2/10 Valdis Vītoliņš <[email protected]>
Maybe it is bad design for custom solution, but for management simplicity I store different objects (values for database lists for form selections) in the same space.
Now they are quite many and listing class name for this object would help. Your code require iteration over all used classes, and searching for appropriate documents. I assume, more efficient way would be starting from documents and finding their classes.
Another solution would be adding prefix in names, to distinguish them, but this requires data changes.
Valdis
On 02/10/2010 05:43 PM, Valdis Vītoliņš wrote:
Can somebody provide code snippet how to got associated class name for documents in space which have added custom objects?
e.g. this simply list different objects in space {{velocity}} #set($hql = "where doc.space='Custom' order by doc.name asc") #set($results = $xwiki.searchDocuments($hql, 0, 0)) #foreach ($item in $results) * [[$item]] #end {{/velocity}}
and I'd like to get class names for different types of listed docs/objects
Thanks in advance, Valdis
I'm not sure I understand the question. Do you want to list all documents in a space having an object from a given type?
", BaseObject obj where doc.space='Custom' and obj.name=doc.fullName and obj.className='Custom.MyClass'"
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users