Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 713 posts 954 karma points
    Mar 07, 2011 @ 05:23
    Tom
    0

    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?

  • Sascha Wolter 615 posts 1101 karma points
    Mar 07, 2011 @ 06:54
    Sascha Wolter
    1

    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

  • Tom 713 posts 954 karma points
    Mar 07, 2011 @ 07:04
    Tom
    0
    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?

  • Tom 713 posts 954 karma points
    Mar 07, 2011 @ 07:11
    Tom
    0

    not too sure if I'm spitting out the right xml though!

Please Sign in or register to post replies

Write your reply to:

Draft