Copied to clipboard

Flag this post as spam?

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


  • FarmFreshCode 225 posts 422 karma points
    Jun 20, 2011 @ 17:34
    FarmFreshCode
    0

    Move "Related Posts" under Current post

    Hello Anthony, 

    I am trying to display the related posts under my current post instead of having them over on the right hand column.. I am trying to tweak the uBlogsyShowPost.cshtml file in order to do so. I have included the code at the bottom of this file and shown where I would like to be able to display the related posts. 

     @if (Model.NodeTypeAlias == "uBlogsyPost"){
    
    <!-- ************ INSERT RELATED POSTS HERE ************ -->
    
       DynamicNode prev = NodeHelper.GetNextPost(d);
                DynamicNode next = NodeHelper.GetPreviousPost(d);
    
                <div class="uBlogsy_next_prev">
    
                    @if (prev != null){
                        <a href="@prev.Url" class="uBlogsy_prev">Older Posts</a>
                    }
    
    
                    @if (next != null)
                    {
                        <a href="@next.Url" class="uBlogsy_next">Newer Posts</a>
                    }
    
                </div>
    
            }
        </div>
    }

    I've been looking at the code located in the uBlogsyListRelatedPosts.cshtml file but haven't been able to successfully move it over and incorporate it into my uBlogsyPost display. 

    Could you possibly show me the bit of code I need to include here to make the related posts show up?

    Thank you... 

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jun 20, 2011 @ 19:25
    Anthony Dang
    2

    The issue is that the script needs parameters. eg. @Parameter.ItemCount. So you cant simply include the script or copy and paste the code. You have to do a check for the parameters.

     

     This is what you want in the top of uBlogsyListRelatedPosts.cshtml

        int count;
        string relatedAlias;
        int matchCount;
    
        if (PageData.Count > 0){
            count = PageData[0];
            relatedAlias = PageData[1];
            matchCount = PageData[2];
        }
        else{
            // get item count
            count = int.Parse(@Parameter.ItemCount);
    
            // can be uBlogsyPostTags, uBlogsyPostCategories, or empty string (gets both)
             relatedAlias = @Parameter.RelatedAlias;
    
            // get number of items to match
             matchCount = int.Parse(@Parameter.MatchCount);
        }
        if (count == -1)
        {
            count = int.MaxValue;
        }
    
    
    
        // get all posts
        DynamicNodeList postList = Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyPost");
    

     

    This is the new line you want in uBlogsyShowPost. Tweak the parameters as required.

    
    @RenderPage("/macroScripts/uBlogsyListRelatedPosts.cshtml", 5, "", 1) 
    
  • FarmFreshCode 225 posts 422 karma points
    Jun 20, 2011 @ 19:39
    FarmFreshCode
    0

    Ah... Thanks.. works great. 

Please Sign in or register to post replies

Write your reply to:

Draft