blogpostlist on folder name based multiple sites

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/13/2021 5:22:45 AM
Gravatar
Total Posts 2

blogpostlist on folder name based multiple sites

I am a bit surprised I can't find any reference to this situation... but it seems BlogPostList control has problems in name-based multi-tenancy mode. I have Blogs on a child sites (mapped to some folder named "yyy" or "xxx" or whatever), then I have a BlogPostList on child site that displays last posts of a blog control. But links in BlogPostList posts are wrong. They link to root site instead to the subfolder based child site.

I tried to solve the issue in razor template of the BlogPostList somwhow, but also got stuck. If you use "@Request.Url" in razor template, the default root page "root/default.aspx" is referenced, not the actual page in subfolder where the BlogPostList instance is running.

Can you please provide any help?

5/17/2021 3:29:10 PM
Gravatar
Total Posts 2253

Re: blogpostlist on folder name based multiple sites

Hello,

I've found the problem with this and have fixed it in our code. 

To work around the problem, use the following view as an example. Basically, you ned need to add @using mojoPortal.Web; to the top and then @SiteUtils.GetNavigationSiteRoot() in front of each instance of @item.ItemUrl and @Model.ModulePageUrl.

@using mojoPortal.Web.Helpers;
@using mojoPortal.Business;
@using mojoPortal.Web; @*add mojoPortal.Web to this line *@
@model PostListModel

<div class="blog-postlist">
    @foreach (var item in Model.Posts)
    {
        <article class="blog-postlist__item">

            <header>
                @if (!string.IsNullOrWhiteSpace(item.HeadlineImageUrl))
                {
                    <figure class="blog-postlist__item-featured-image">
                        <img src="@item.HeadlineImageUrl" alt="@item.Title" />
                    </figure>
                }

                <h2 class="blog-postlist__title">
                    <a class="blog-postlist__item-link" href='@SiteUtils.GetNavigationSiteRoot()@item.ItemUrl'>@item.Title</a> 
                </h2>
                @if (@item.SubTitle != "")
                {
                    <h3 class="blog-postlist__sub-title">@item.SubTitle</h3>
                }
            </header>

            <div class="blog-postlist__item-body">
                @Html.Raw(item.Body)
            </div>

            <footer>
                <div class="blog-postlist__metadata">
                    @if (item.ShowAuthorName)
                    {
                        <span class="blog-postlist__author">
                            @if (item.ShowAuthorAvatar && !item.ShowAuthorBio)
                            {
                                <span class="blog-postlist__author-avatar">
                                    @Html.Avatar(item.AuthorAvatar, item.AuthorEmail, item.AuthorUserId, new { Class = "author__avatar" }, new { Class = "author__avatar-link" }, true, true)
                                </span>
                            }
                            <span class="blog-postlist__author-name">
                                @if (!item.ShowAuthorAvatar || item.ShowAuthorBio)
                                {
                                    <i class="fa fa-user-circle"></i>
                                }
                                @item.AuthorDisplayName
                            </span>
                        </span>
                    }

                    <span class="blog-postlist__date"><i class="fa fa-clock-o"></i> @item.PostDate.ToString("MMMM dd, yyyy")</span>

                    @if (item.AllowCommentsForDays > -1)
                    {
                        <span class="blog-postlist__comments"><a class="blog-postlist__commentslink" href="@SiteUtils.GetNavigationSiteRoot()@item.ItemUrl#comments"><i class="fa fa-comments"></i> @Resources.BlogResources.BlogFeedbackLabel (@item.CommentCount)</a></span> 
                    }
                </div>

                @if (item.ShowAuthorBio)
                {
                    <div class="author__group author__group--blog-postlist media">
                        @if (item.ShowAuthorAvatar)
                        {
                            @Html.Avatar(item.AuthorAvatar, item.AuthorEmail, item.AuthorUserId, new { Class = "author__avatar media-object" }, new { Class = "author__avatar-link media-left" }, true, true)
                        }

                        @if (item.ShowAuthorBio && !string.IsNullOrWhiteSpace(item.AuthorBio))
                        {
                            <p class="author__bio media-body">@item.AuthorBio</p>
                        }
                    </div>
                }

            </footer>
        </article>
    }
    <p><a href="@SiteUtils.GetNavigationSiteRoot()@Model.ModulePageUrl">View all posts</a> &#187;</p> 
</div>
5/18/2021 10:26:28 AM
Gravatar
Total Posts 2

Re: blogpostlist on folder name based multiple sites

Thank you, it works!

Just one more question, if may I... I guess there is no possibility that the same razor template would be used for BlogPostList and for the Blog? So that blog posts in both would look the same?

You must sign in to post in the forums. This thread is closed to new posts.