Hi Colin - you're right, you have no access to unpublished content from XSLT without using some sort of extension function (can't help you with one, either)
Following up on Chriztian's comment, the unpublished content is not written to the XML cache - hence why it isn't available to you in XSLT.
My thinking is that you might need to re-think your solution ... why do you want to list unpublished documents/nodes?
If it's a case of just hiding them from various parts of the front-end, e.g. navigation, news listings, etc. Then you could make use of the "umbracoNaviHide" property in your doc-types? (We can explain more if you think that's a good approach?)
Sorry for being unclear on my intentions with the code, it has to do with the fact that I do not want to unintentionally release information I shouldn't.
However I can describe the intended functionality as follows:
There are members that can register on a site
Each of these members has a page on the site where they can publish information
They can add certain 'subjects' to these pages, and only subjects they have filled in and/or are approved are shown
All information members submit are held for moderation and have the state unpublished
Admins (moderators) check and can preview this information before publication
The member pages and subjects are custom document types (due to the requirements and they are not included in any menu). Subjects are children of the member page.
For the member pages we have a template that displays all the information. And uses a generated menu that uses javascript to switch the content if you select a subject (this data is prefilled, so no refresh or new request).
The problem arises when admins preview this content. As a preview of a member page will not show the different added subjects if they are not published. I'm trying to figure out a good way to allow a preview to include and display these unpublished subjects.
My current idea for solving this is the following:
Adapt the macro that it uses the umbraco api to pull in the content and display it if it is published (so no longer use XSLT for pulling in the data)
Add logic that if the member page is in preview mode the member page displays published and unpublished subjects.
If you really need to access unpublished documents then you could go use the Umbraco Document API This should give you programmatic access to unpublished nodes. Look at the umbraco.cms.businesslogic.web.Document class. Your best bet would be to do this via Razor macros, but if not then you'd need to write some XSLT exctensions to do this.
But I'd consider first whether you really need to do this? You could hide nodes (and protect them from acess by adding them to a member group or something).
Pulling unpublished content?
I'm wondering if it's possible to adapt this query so that it pulls unpublished content?
<xsl:for-each select="$currentPage/*/* [@isDoc]">
(I suspect this isn't possible, but I just want to check this before I write a macro that does this for me)
Hi Colin - you're right, you have no access to unpublished content from XSLT without using some sort of extension function (can't help you with one, either)
/Chriztian
Hi Colin,
Following up on Chriztian's comment, the unpublished content is not written to the XML cache - hence why it isn't available to you in XSLT.
My thinking is that you might need to re-think your solution ... why do you want to list unpublished documents/nodes?
If it's a case of just hiding them from various parts of the front-end, e.g. navigation, news listings, etc. Then you could make use of the "umbracoNaviHide" property in your doc-types? (We can explain more if you think that's a good approach?)
Cheers, Lee.
Sorry for being unclear on my intentions with the code, it has to do with the fact that I do not want to unintentionally release information I shouldn't.
However I can describe the intended functionality as follows:
The member pages and subjects are custom document types (due to the requirements and they are not included in any menu). Subjects are children of the member page.
For the member pages we have a template that displays all the information. And uses a generated menu that uses javascript to switch the content if you select a subject (this data is prefilled, so no refresh or new request).
The problem arises when admins preview this content. As a preview of a member page will not show the different added subjects if they are not published. I'm trying to figure out a good way to allow a preview to include and display these unpublished subjects.
My current idea for solving this is the following:
I hope this makes sense.
Why not have a property somewhere called "Approved" then in your XSLT just show nodes which have been approved?
If you really need to access unpublished documents then you could go use the Umbraco Document API This should give you programmatic access to unpublished nodes. Look at the umbraco.cms.businesslogic.web.Document class. Your best bet would be to do this via Razor macros, but if not then you'd need to write some XSLT exctensions to do this.
But I'd consider first whether you really need to do this? You could hide nodes (and protect them from acess by adding them to a member group or something).
is working on a reply...