Anyone have a better way of doing this? Is there any problem using the getContentOfContentType method of a document? And why wouldnt this method return an array of documents instead of an array of umbraco.cms.busniesslogic.Content?
This is a control in the backend to list documents, and filter them by diffrent criterias. Also it needs to be unpublished documents also, which means, xml, nodefactory and so on is out of the question. Wondering what methods is the best to grab all documents of a certain type. Either using this method and the converting the result to a list och documents or traversing all documents looking for the correct type....
Nope, this is an Umbraco 4.0.4.2 so I dont have access to any better methods :-(. Also I have to wait to get a 3.5 compile of the 4.5 before I can upgrade :-(
Thanks for your response. Will continue on my project on the path I have set then and not worry about this anymore :-)
As far as I'm aware, (also from looking at the core code via Reflector), checking for "-20" in the path is the best way. In fact that's the way Document.delete() checks it...
... forgot to mention, in v4.5 (which I know you aren't using yet), there is a property called IsTrashed in the CMSNode class/object (which Content inherits from - thus available in Document too).
But I can tell you now that as your site grows what you're wanting to do will get slower and slower, and this is an unfortunate hold-over from the current data layer design.
Get all documents by document type?
Need to get all documents, unpublished and published content for a certain document type. Thought of using this code do so:
Anyone have a better way of doing this? Is there any problem using the getContentOfContentType method of a document? And why wouldnt this method return an array of documents instead of an array of umbraco.cms.busniesslogic.Content?
Does it have to be in a .NET User Control, cant you just use XSLT?
Something like
Tom
This is a control in the backend to list documents, and filter them by diffrent criterias. Also it needs to be unpublished documents also, which means, xml, nodefactory and so on is out of the question. Wondering what methods is the best to grab all documents of a certain type. Either using this method and the converting the result to a list och documents or traversing all documents looking for the correct type....
Hi Anders, I'd say you are taking the best approach to this already.
If you are using v4.5, then there's a new API call in the Document class/object called: "GetDocumentsOfDocumentType()", try that one instead.
Cheers, Lee.
Nope, this is an Umbraco 4.0.4.2 so I dont have access to any better methods :-(. Also I have to wait to get a 3.5 compile of the 4.5 before I can upgrade :-(
Thanks for your response. Will continue on my project on the path I have set then and not worry about this anymore :-)
/Anders
To follow up on this subject. Is there any better way to check if the "document" is in the trashbin other than checking if the path contains -20?
Seam that when using the "content" as the base for getting a list of documents one also gets the items in the trashbin.
As far as I'm aware, (also from looking at the core code via Reflector), checking for "-20" in the path is the best way. In fact that's the way Document.delete() checks it...
... forgot to mention, in v4.5 (which I know you aren't using yet), there is a property called IsTrashed in the CMSNode class/object (which Content inherits from - thus available in Document too).
There is a 3.5 release of Umbraco 4.5, it's just that codeplex doesn't have the appropriate web.config on it yet. See this post: http://our.umbraco.org/forum/core/41-feedback/10084-35-for-45
But I can tell you now that as your site grows what you're wanting to do will get slower and slower, and this is an unfortunate hold-over from the current data layer design.
Ok. Will have to check up on how to upgrade to 4.5, have lots of xslts so if that will be a hassle to upgrade I have no choise at the moment.
/Anders
You can set a flag in the umbracoSettings.config which will leave the schema of the XML unchanged.
Yeah I read that somewhere. But will one get the improved speed and such then?
Not improved XPath speed, but the database improvements are agnostic of the XML schema
Ok, maybe I try an upgrade later today then.
Thanks for the help!
is working on a reply...