Copied to clipboard

Flag this post as spam?

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


  • Bobi 346 posts 950 karma points
    Feb 22, 2017 @ 19:13
    Bobi
    0

    Calling Partial views into homepage

    Hi,

    I have a question that seems to be driving me mad. How can I pull a partial view into my home page simple? I just want to reference:

    @Html.ThemedPartial(Model, "Latest")

    (which is from Articulate blog). However, I am not sure how to do this because I do not know what using directives to include, etc.? Is there an easy way to do this?

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Feb 22, 2017 @ 22:09
    Dennis Aaen
    0

    Hi Bobi,

    Try to see this documentation about Partial Views in Umbraco CMS https://our.umbraco.org/documentation/reference/templating/mvc/partial-views

    When you need to call a Partial views into homepage template then you can do it like this.

    @Html.Partial("MyPartialName", Model)
    

    Hope this helps,

    /Dennis

  • Bobi 346 posts 950 karma points
    Feb 23, 2017 @ 05:39
    Bobi
    0

    Thanks. I even tried:

    @Html.Partial("/Views/Latest.cshtml", new Articulate.Models.ListModel(Umbraco.Content(1066)))
    

    but had no luck.

    When I try:

    @Html.Partial("~/App_Plugins/Articulate/Themes/MyTheme/Views/Partials/Latest.cshtml", Model)
    

    I get the following error:

    Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedContentModels.Index to model type Articulate.Models.IMasterModel.
    

    I also tried modifying the directives to

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Articulate.Models.PostModel>
    

    But I then get the following error:

     CS0426: The type name 'Models' does not exist in the type 'Umbraco.Web.PublishedContentModels.Articulate'
    
  • Michaela Ivanova 12 posts 104 karma points
    Jun 21, 2017 @ 07:40
    Michaela Ivanova
    0

    Make sure the model in the partial is the same as the one you use in the Html.Partial. Try making the model in the partial IPublishedContent, this should do the trick for your case. Just try:

    @Html.Partial("~/App_Plugins/Articulate/Themes/MyTheme/Views/Partials/Latest.cshtml", Model) and make sure the model in the partial is IPublishedContent

Please Sign in or register to post replies

Write your reply to:

Draft