Copied to clipboard

Flag this post as spam?

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


  • Kiel Diller 24 posts 72 karma points
    Mar 21, 2013 @ 21:58
    Kiel Diller
    0

    2 Blog Site will not show 2 blog rolls on same page

    I have a site with 2 blogs installed, landing pages 1072 and 1277 (FWIW). On my home page, I'm trying to render 2 different macros that point to 2 different .cshtml files to give me the newest 3 posts from each blog.

    I tried changing variable names thinking they were conflicting, no change. I added little

    tags to see if they were rendering the wrong macro's, and they were not.

    The output is great until the actual items are output. What is going on?!

    The contents of the CSHTML files are below:

    @using System.Linq
    @using System.Xml.Linq
    @using umbraco.MacroEngines
    @using uBlogsy.Common.Extensions
    @using uBlogsy.Common.Helpers
    @using uBlogsy.BusinessLogic
    @{
    
        int blog_count = int.Parse(@Parameter.ItemCount);

    IEnumerable<DynamicNode> blog_nodes;

    var blog_posts = PostService.Instance.GetPosts(1072);
    if(blog_posts == null){
    <p>No Posts...</p>
    }
    else{
    blog_nodes = ((IEnumerable<DynamicNode>)blog_posts).Take(blog_count);
    <p>abc</p>
    <ul id="blog_list">
    @foreach (DynamicNode n2 in blog_nodes)
    {
    <li>
    <a href="@n2.Url" title="@n2.GetProperty("uBlogsyContentTitle").Value">
    <span>@n2.GetProperty("uBlogsyContentTitle").Value</span>
    </a>
    </li>
    }
    </ul>
    }
    @using System.Linq
    @using System.Xml.Linq
    @using umbraco.MacroEngines
    @using uBlogsy.Common.Extensions
    @using uBlogsy.Common.Helpers
    @using uBlogsy.BusinessLogic
    @{
    
        int count = int.Parse(@Parameter.ItemCount);

    IEnumerable<DynamicNode> nodes;

    var posts = PostService.Instance.GetPosts(1277);
    if(posts == null){
    <p>No Posts...</p>
    }
    else{
    nodes = ((IEnumerable<DynamicNode>)posts).Take(count);
    <p>def</p>
    <ul>

    @foreach (DynamicNode n1 in nodes)
    {
    <li>
    <a href="@n1.Url" title="@n1.GetProperty("uBlogsyContentTitle").Value">
    <span>@n1.GetProperty("uBlogsyContentTitle").Value</span>
    </a>
    </li>
    }
    </ul>
    }
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 21, 2013 @ 22:53
    Anthony Dang
    0

    uBlogsy wont do this.

    It searches up the tree to find the landing node, then caches it in the request. Any subsequent request (from another script) will hit the same node.

    A work around "could" be to use the blogroll script to reference the rss feed of the 2nd blog... but it's a bit hacky.

     

     

  • Kiel Diller 24 posts 72 karma points
    Mar 22, 2013 @ 13:45
    Kiel Diller
    0

    No go. I tried a few things and nothing ever changed.

    Any other ideas on how to trick this? I can't imagine this is unheard of, especially in a multi-blog situation. Maybe multi-blog situations are uncommon...

    I don't mind hacky, if it works.

  • Kiel Diller 24 posts 72 karma points
    Mar 22, 2013 @ 15:29
    Kiel Diller
    0

    OK, so I found a workaround. Yes it's probably not a good one, but it works!

    I changed my scripts to just NOT use the ublogsy functions and did it with DynamicNodes.

    int count = int.Parse(@Parameter.ItemCount);

    var blogRoot = (new DynamicNode(1301));

    if(blogRoot.HasAccess){
    var posts = blogRoot.Descendants().Where(x => x.NodeTypeAlias == "uBlogsyPost").OrderByDescending(x => x.GetProperty("uBlogsyPostDate").Value).Take(count);
    if(posts == null){
    <p>No Posts...</p>
    }
    else
    {
    <ul>

    @foreach (DynamicNode n1 in posts)
    {
    <li>
    <a href="@n1.Url" title="@n1.GetProperty("uBlogsyContentTitle").Value">
    <span>@n1.GetProperty("uBlogsyContentTitle").Value</span>
    </a>
    </li>
    }
    </ul>
    }

    }

    else
    {
    <div class="alert alert-info">Please log in to view this content.</div>
    }

    I also changed the other script to follow this one and they work like a charm.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 22, 2013 @ 15:56
    Anthony Dang
    0

    Yes that works too. Der. I don't know why I didnt think of that. #h5is

     

Please Sign in or register to post replies

Write your reply to:

Draft