I have an instance where I'd like to be able to get a list of unpublished nodes in xslt to display to a member of a certain group when they login so that the user can see a list of items they need to review and publish..
is it possible in xslt to get a list of unpublished nodes?
I don't think this is possible with the given functionality out of the box. The Xslt operates on the umbraco.config XML cache, which contains only published nodes, the unpublished ones are for the web site not relevant and would only make the cache bigger without any use.
In order to access unpublished nodes in your Xslt you would need to write your own Xslt extension which uses e.g. the Document object to access the database (can't use Linq2Umbraco either as it operates on umbraco.config as well). Then you can loop through the list of Documents and only return those in an XPathNodeIterator which are not published.
Alternatively you could add another field to your documents which flags if a content node is a 'draft' or 'live' (plus a usercontrol which redirects to another page if someone wants to access a drafted document). That way your documents would be in the umbraco.config file and you could access them without any problems.
var nodes = new List<XPathNavigator>();
Document rootDoc = new Document(startNodeId);
if (rootDoc != null)
{
foreach (var childDoc in rootDoc.GetDescendants().Cast<Document>().Where(d => !d.Published))
{
XmlDocument xmlDoc = new XmlDocument();
nodes.Add(rootDoc.ToXml(xmlDoc,false).CreateNavigator());
}
}
return new XPathNavigatorWrapperIterator(nodes);
This of course hasn't been finalised but am thinking something like this!
Will I need to create a dummy backend login in order to be able to publish the node on the front-end?
Preview & Publish on front end
Hi Guys
I have an instance where I'd like to be able to get a list of unpublished nodes in xslt to display to a member of a certain group when they login so that the user can see a list of items they need to review and publish..
is it possible in xslt to get a list of unpublished nodes?
Hi Tom,
I don't think this is possible with the given functionality out of the box. The Xslt operates on the umbraco.config XML cache, which contains only published nodes, the unpublished ones are for the web site not relevant and would only make the cache bigger without any use.
In order to access unpublished nodes in your Xslt you would need to write your own Xslt extension which uses e.g. the Document object to access the database (can't use Linq2Umbraco either as it operates on umbraco.config as well). Then you can loop through the list of Documents and only return those in an XPathNodeIterator which are not published.
Alternatively you could add another field to your documents which flags if a content node is a 'draft' or 'live' (plus a usercontrol which redirects to another page if someone wants to access a drafted document). That way your documents would be in the umbraco.config file and you could access them without any problems.
Hope that helps,
Sascha
This of course hasn't been finalised but am thinking something like this!
Will I need to create a dummy backend login in order to be able to publish the node on the front-end?
not too sure if I'm spitting out the right xml though!
is working on a reply...