Copied to clipboard

Flag this post as spam?

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


  • Ishan Vyas 67 posts 198 karma points
    Sep 18, 2018 @ 10:22
    Ishan Vyas
    0

    Partial views in creating site from scratch

    while using partial views in the blog post I don't get the title of the blog when a specific blog is selected. it shows on the blog list but not when the specific blog is selected for viewing it.

    This is the Blog page where you can see the title:enter image description here

    Here when going to specific blog I don't see the blog title

  • Jesper Mayntzhusen 7 posts 80 karma points c-trib
    Sep 18, 2018 @ 10:41
    Jesper Mayntzhusen
    1

    Hey Ishan,

    It looks like this is just because it is two different views that are used?

    Can you maybe paste the code behind this here so there is something to work with? 😁

  • Ishan Vyas 67 posts 198 karma points
    Sep 18, 2018 @ 10:54
    Ishan Vyas
    0

    Actually I am new to umbraco so I am following the tutorials and learning from it how to build a site from scratch.

  • Ishan Vyas 67 posts 198 karma points
    Sep 18, 2018 @ 10:52
    Ishan Vyas
    0

    this is the blog item template code

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.BlogItem>
    

    @using ContentModels = Umbraco.Web.PublishedContentModels; @{ Layout = "Master.cshtml"; }

                                                        <!-- Featured Post -->
                                                            <article class="box post">
                                                                <header>
                                                                    <h3><a href="#">@Umbraco.Field("blogTitle")</a></h3>
                                                                    <p></p>
                                                                    <ul class="meta">
                                                                        <li class="icon fa-clock-o">15 minutes ago</li>
                                                                        <li class="icon fa-comments"><a href="#">8</a></li>
                                                                    </ul>
                                                                </header>
                                                                <a href="#" class="image featured"><img src="/images/pic05.jpg" alt="" /></a>
                                                                <p>
                                                                    @Umbraco.Field("blogTeaser")
                                                                </p>
                                                                <a href="#" class="button">Continue Reading</a>
                                                            </article>
    
    
                                                    </div>
                                                </div>
    
    
    
    
                                                <div class="col-3 col-12-medium">
                                                    <div class="sidebar">
    
                                                        <!-- Archives -->
                                                            <ul class="divided">
                                                                <li>
                                                                    <article class="box post-summary">
                                                                        <h3><a href="#">1 Subheading</a></h3>
                                                                        <ul class="meta">
                                                                            <li class="icon fa-clock-o">6 hours ago</li>
                                                                            <li class="icon fa-comments"><a href="#">34</a></li>
                                                                        </ul>
                                                                    </article>
                                                                </li>
                                                                <li>
                                                                    <article class="box post-summary">
                                                                        <h3><a href="#">Another Subheading</a></h3>
                                                                        <ul class="meta">
                                                                            <li class="icon fa-clock-o">9 hours ago</li>
                                                                            <li class="icon fa-comments"><a href="#">27</a></li>
                                                                        </ul>
                                                                    </article>
                                                                </li>
                                                                <li>
                                                                    <article class="box post-summary">
                                                                        <h3><a href="#">And Another</a></h3>
                                                                        <ul class="meta">
                                                                            <li class="icon fa-clock-o">Yesterday</li>
                                                                            <li class="icon fa-comments"><a href="#">184</a></li>
                                                                        </ul>
                                                                    </article>
                                                                </li>
                                                                <li>
                                                                    <article class="box post-summary">
                                                                        <h3><a href="#">And Another</a></h3>
                                                                        <ul class="meta">
                                                                            <li class="icon fa-clock-o">2 days ago</li>
                                                                            <li class="icon fa-comments"><a href="#">286</a></li>
                                                                        </ul>
                                                                    </article>
                                                                </li>
                                                                <li>
                                                                    <article class="box post-summary">
                                                                        <h3><a href="#">And One More</a></h3>
                                                                        <ul class="meta">
                                                                            <li class="icon fa-clock-o">3 days ago</li>
                                                                            <li class="icon fa-comments"><a href="#">8,086</a></li>
                                                                        </ul>
                                                                    </article>
                                                                </li>
                                                            </ul>
                                                            <a href="#" class="button alt">Archives</a>
    
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </section>
    
                            </div>
                        </div>
                    </div>
                </section>
    

    This one is for the blog page template:-

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.BlogPage>
    

    @using ContentModels = Umbraco.Web.PublishedContentModels; @{ Layout = "Master.cshtml"; }

    <div class="col-12">
                                <!-- Blog -->
                                    <section class="box blog">
                                        <h2 class="major"><span>@Umbraco.Field("blogTitle")</span></h2>
                                        <div>
                                            <div class="row">
                                                <div class="col-9 col-12-medium">
                                                    <div class="content">
    
                                                    @Html.Partial("ListBlogItems")  
    
                                                    </div>
                                                </div>
                                                <div class="col-3 col-12-medium">
                                                    <div class="sidebar">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
    
                                    </section>
    
    </div>                                                          
    

    And this is the partial view i want to create for displaying it in 3 different regions:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.BlogPage>
    

    @using ContentModels = Umbraco.Web.PublishedContentModels; @{ Layout = "Master.cshtml"; }

    <div class="col-12">
                                <!-- Blog -->
                                    <section class="box blog">
                                        <h2 class="major"><span>@Umbraco.Field("blogTitle")</span></h2>
                                        <div>
                                            <div class="row">
                                                <div class="col-9 col-12-medium">
                                                    <div class="content">
    
                                                    @Html.Partial("ListBlogItems")  
    
                                                    </div>
                                                </div>
                                                <div class="col-3 col-12-medium">
                                                    <div class="sidebar">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
    
                                    </section>
    
    </div>                                                          
    
  • Jesper Mayntzhusen 7 posts 80 karma points c-trib
    Sep 18, 2018 @ 11:00
    Jesper Mayntzhusen
    0

    No worries, I am still fairly new to Umbraco myself, we all start somewhere 😉

    I think your problem is that you are using different models here:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.BlogItem>
    
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.BlogPage>
    

    It seems when you are using BlogItem you get the name and when you are using BlogPage you are not, my guess is that BlogPage is just a parent container of the the actual BlogPage 🙂

  • Ishan Vyas 67 posts 198 karma points
    Sep 18, 2018 @ 11:07
    Ishan Vyas
    0

    yes but in the partial view they inherit both of them. its what I guess is because we have declared blog item as child of blog page.

    in partial view they are rendering both models I guess to my knowledge.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{ var selection = Model.Content.Site().FirstChild("blogPage").Children("blogItem") .Where(x => x.IsVisible()); }

Please Sign in or register to post replies

Write your reply to:

Draft