Copied to clipboard

Flag this post as spam?

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


  • Billy Wagner 1 post 71 karma points
    Oct 21, 2017 @ 02:23
    Billy Wagner
    0

    Adding Articulate Blog Posts To Sitemap

    I have read that someone couldn't get Robert Fosters Sitemap to update with Articulates Blog posts Soooo I did a bit of code because I needed it too.

    I added a property called ArticulateID in the sitemap document type which allows me to set an id for the sitemap to pickup that id and include the blog posts as well. I run multiple sites so I just simple add sitemap and articulate to the root and get articulates id and put it in the sitemap property. Pretty easy I think. Anyway Umbraco formatted this code a bit weird so hopefully you'll be able to replicate.


    @using Articulate
    

    @using Articulate.Models @using System.Linq @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{Layout = null;} @helper ListChildNodes(IPublishedContent startNode) { Response.ContentType = "text/xml"; const int maxLevelForSiteMap = 1000; foreach(var node in startNode.Children .Where(n => n.IsVisible() && n.TemplateId > 0 && !Umbraco.IsProtected(n.Id, n.Path) && (!n.HasProperty("searchEngineSiteMapHide") || !n.GetPropertyValue

    @helper ListArticulateNodes() {

    if(@Model.Content.GetPropertyValue("ArticleNodeID") != "")
    {
    
    var newsroot = Umbraco.TypedContent(@Model.Content.GetPropertyValue("ArticleNodeID"));
    var blogArchive = newsroot.Children.First();
    
    Response.ContentType = "text/xml";
    const int maxLevelForSiteMap = 1000;
    
    foreach(var node in blogArchive.Children)
    
    {
    <url>
        <loc>@(((IPublishedContent)node).UrlWithDomain())</loc>
        <lastmod>@node.UpdateDate.ToString("s")+00:00</lastmod>
    </url>
        if (node.Level <= maxLevelForSiteMap)
        {
            @ListChildNodes(node)
    
        }
    
    }
    

    } }


  • 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