Copied to clipboard

Flag this post as spam?

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


  • Paul de Quant 403 posts 1521 karma points
    May 11, 2016 @ 15:18
    Paul de Quant
    0

    Hiding unpublished pages

    Hello,

    I have a sitemap, which is still showing a page that should have been removed as the Unpublished At date was reached.

    What criteria do I need to check for to make sure I filter out this page.

    The code I have:

     @traverse(CurrentPage.AncestorOrSelf(1))
    
                @helper traverse(dynamic node)
                {
                    var cc = node.Children.Where("hideFromNavigation!=true");
                    if (cc != null)
                    {
                        <ul>
                            @foreach (var c in cc)
                            {
                                <li>
                                    <a href="@c.Url">@c.Name</a>
                                    @traverse(c)
                                </li>
                            }
                        </ul>
                    }
                }
    

    Thanks

    Paul

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    May 11, 2016 @ 18:53
    Marc Goodson
    100

    Hi Paul

    It looks like the page hasn't been successfully unpublished at the Unpublished At date.

    Can you check in the Umbraco backoffice to see if it has been unpublished ?

    if the page has been successfully unpublished then it's details will not be in the Umbraco Xml Cache file, and so won't appear in node.Children

    (regardless of the Where filter, which you have correct if hideFromNavigation is the alias of your property that shows and hides pages in navigation - incidentally there is an Umbraco convention, that says if you call the alias of this property umbracoNaviHide then you can query .Where("Visible") )

    There may be a number of reasons why unpublished at isn't automatically unpublishing your item at the specified date/time.

    There is an open issue: http://issues.umbraco.org/issue/U4-5562

    or it may be your configuration preventing scheduled tasks from running, the trace log files in /app_data/logs should give some clues to the error if this is the case.

    regards

    Marc

  • Paul de Quant 403 posts 1521 karma points
    May 12, 2016 @ 07:39
    Paul de Quant
    0

    Hi Marc,

    I suspect you're right. I've checked the node tree again in the admin section and I can see that the page status never changed to unpublish once the unpublish date had been reached.

    If I manually unpublish the page, I can see my code works and the page is removed from the site map.

    Hopefully Umbraco will come up with a fix soon.

    Alternatively do you know what the alias name is on Unpublish At?

    Thanks

    Paul

  • Manish 373 posts 932 karma points
    May 12, 2016 @ 07:10
    Manish
    0

    Hi

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using System.Linq;
    @{
        Layout = null;
        Response.ContentType = "text/xml";
    }<?xml version='1.0' encoding='UTF-8' ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
        @ListChildNodes(Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1))
    </urlset>
    
    @helper ListChildNodes(IPublishedContent startNode)
    {
    
        foreach (var node in startNode)
        {
             // do your stuff
        }
    }
    

    I have checked this and it is fine here.

    Manish

  • Paul de Quant 403 posts 1521 karma points
    May 12, 2016 @ 07:28
    Paul de Quant
    0

    Hi Manish,

    Thanks for your response.

    I can't seem to get this code to work - also I'm trying to make a conventional sitemap - i.e. one that shows indentations rather that a Google SiteMap which returns everything in a straight list.

    Thanks

    Paul

  • Manish 373 posts 932 karma points
    May 12, 2016 @ 08:26
    Manish
    0

    Hi

    Can you check in DB for the following nodes that they are in unpublished status.

    Manish

  • Naveed Ali 161 posts 426 karma points
    May 12, 2016 @ 12:35
    Naveed Ali
    0

    Hi,

    A note to add to this is when you put in a unpublish date you must press "save" NOT "save and publish"

    Nav

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies