Does anyone know of the "proper" way to tell if a Content object is published.
The two options that I can see are:
a) Create a Document object based on the ID of the Content object and check its Published property - this seems to involve an unnecessary creation of a Document object for such a simple check
b) Check if the path starts with "-1" - this seems to be a bit of a hacky way that may not be future proof.
So it is perfectly possible, I just wondered what the "proper" cheap way is.
simple, if you use XSLT to view the Content, all you get IS published. The umbraco.config-file (which is used when you use XSLT) does not contain unpublished nodes.
If you do want unpublished nodes, then, yes, the only way I know of is to create the document.
How to tell if a Content node is published?
Hi guys,
Does anyone know of the "proper" way to tell if a Content object is published.
The two options that I can see are:
a) Create a Document object based on the ID of the Content object and check its Published property - this seems to involve an unnecessary creation of a Document object for such a simple check
b) Check if the path starts with "-1" - this seems to be a bit of a hacky way that may not be future proof.
So it is perfectly possible, I just wondered what the "proper" cheap way is.
Cheers
Steve
Hi Steve,
simple, if you use XSLT to view the Content, all you get IS published. The umbraco.config-file (which is used when you use XSLT) does not contain unpublished nodes.
If you do want unpublished nodes, then, yes, the only way I know of is to create the document.
HTH,
Peter
Peter's right, if it can't be found using
then it's not published. If you really need to have info on the node, use
(be aware that this latter requires quite some db traffic, so don't use this in the frontend unless it's absolutely necessary)
Cheers,
/Dirk
Hi Guys,
Thanks for the responses. I'm not in XSLT, just plain C#, so the Node node = new Node(id) seems the best way to go.
Inadvertantly Dirk you've brought to my attention the cost of the Document object, which I had not realised, so thanks for that.
Cheers
Steve
is working on a reply...