Copied to clipboard

Flag this post as spam?

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


  • Andy 6 posts 76 karma points
    Jun 01, 2016 @ 06:01
    Andy
    0

    Use Master.cshtml as template

    Hi,

    I am integrating Articulate into an existing site where the site's Master template pulls in navigation, social media and other values set through configuration Doc Types.

    I have tried adding code like:

    @using ContentModels = Umbraco.Web.PublishedContentModels;
    

    @{ Layout = null;

    IEnumerable<IPublishedContent> rootNode = Umbraco.TypedContentAtRoot();
    var homepage = rootNode.Where(x => x.IsDocumentType("homepage")).First();
    var settingsFolder = rootNode.Where(x => x.IsDocumentType("settingsFolder")).First();
    var globalSettings = settingsFolder.Children.Where(x => x.IsDocumentType("globalSettings")).First();
    

    }

    at the top of Master.cshtml in the Articulate theme, but get errors.

    Are there ways I can use the overall template of the site, so that if that is updated, it will format the blog as well.

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jun 01, 2016 @ 07:48
    Shannon Deminick
    0

    Can you please explain what your errors actually are?

  • Andy 6 posts 76 karma points
    Jun 01, 2016 @ 13:44
    Andy
    0

    Yes. And to clarify, I have my Master.cshtml in Templates that defines the , , navigation, social media bar, footer with @RenderBody() in the middle.

    I am trying to utilize this same layout or template for the Articulate blog plugin which has themes.

    In App_Plugins/Articulate/Themes/[My Custom Copied Theme]/Views/master.cshtml I attempted to copy code from my Master.cshtml in Templates, but get the following error right away:


    Line 10: IEnumerable


    Now, I am sure an option is to create a Template in Umbraco rather than the plugin and pull out blog posts, but I would like to leverage all that has been setup in the theme, but get the look of my site wrapped around it.

    Thanks for any help!

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jun 06, 2016 @ 10:25
    Shannon Deminick
    0

    Hi Andy,

    This sort of seems like the same question as this one? assuming you've made some progress on your own with the above error.

    https://our.umbraco.org/projects/starter-kits/articulate/discussions/54733-Articulate-integration-in-existing-site#comment-248626

  • Andy 6 posts 76 karma points
    Jun 06, 2016 @ 12:00
    Andy
    0

    It is, but I do not think I am making any progress other than getting different errors.

    I have never used Umbraco before and only slightly knowledgable of ASP.NET (versus very knowledgable in PHP and open source).

    I was able to get a full site integration done and am majorly stuck on building out a blog with Articulate that matches the design of my site.

    This seems like something that should be out of the box to have a Blog Plugin fit into the existing design of a site rather than total separate themes.

    Given my knowledge level and having looked through a lot of resources out there, I think I've hit a wall on it.

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jun 06, 2016 @ 12:55
    Shannon Deminick
    0

    Hi Andy,

    Probably best to start simple here so you understand what is happening. What you want to do is totally possible you just have to understand what a layout is and the model it uses.

    Hopefully you read my reply since you are already pretty close: https://our.umbraco.org/projects/starter-kits/articulate/discussions/54733-Articulate-integration-in-existing-site#comment-248672

    Let's take your List.cshtml for example. It requires a model of type Articulate.Models.ListModel which implements IPublishedContent.

    1. Manually create a new/blank master template file at ~/Views/MasterTest.cshtml to test against
    2. Put this header in your MasterTest.cshtml file: @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>. This means that your Layout will always require that any page that is using it has a model of type IPublishedContent. It's worth noting that normal Umbraco templates by default have a model of type RenderModel but the UmbracoViewPage has some logic in it to convert between these two models so it doesn't care.
    3. Put some simple template markup in it: <html><body>@RenderBody()</body></html>
    4. Change your List.cshtml file to point to that layout: `Layout = "~/Views/MasterTest.cshtml"
    5. The page and layout file should work without error

    It would also be really helpful if you can list the full errors you are getting as your above post just tells me what code is causing an error but not what the error actually is.

  • Andy 6 posts 76 karma points
    Jun 06, 2016 @ 23:45
    Andy
    0

    I am working on trying, but just out of curiosity, my Master currently has:

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

    @using ContentModels = Umbraco.Web.PublishedContentModels;

    @{ Layout = null;

    IEnumerable<IPublishedContent> rootNode = Umbraco.TypedContentAtRoot();
    var homepage = rootNode.Where(x => x.IsDocumentType("homepage")).First();
    var settingsFolder = rootNode.Where(x => x.IsDocumentType("settingsFolder")).First();
    var globalSettings = settingsFolder.Children.Where(x => x.IsDocumentType("globalSettings")).First();
    

    }

    Is that not the correct way as all templates reference

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jun 07, 2016 @ 12:18
    Shannon Deminick
    0

    Hi Andy,

    I'm not exactly sure what you are asking in your question. Is this your Master.cshtml page for your Articulate theme, or is this a Master.cshtml file in your normal ~/Views folder?

    If you have common UI structure that you want to use between your views, then you should use a Layout page - this is what that other post is all about and is what I'm assuming you were originally trying to do above. You can not just use @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Master> for an Articulate view since that model has nothing to do with Articulate.

    Your Layout page in MVC will use the Model that is given to it from the View that is being rendered. Layout pages do not operate outside of the View, they become part of the View. If you strongly type your Layout's model, then you won't be able to use that Layout with a View that does not have the same Model. This is a commonly asked question regarding ASP.Net MVC and I know can cause some confusion but this is how ASP.Net MVC is structured.

    If you want to be able to use your Layout page between Views that have various models, you will need to make sure your Layout page uses a base model type for all of your Views - in the Umbraco world, this is IPublishedContent

  • Andy 6 posts 76 karma points
    Jun 13, 2016 @ 00:19
    Andy
    0

    Thank you. I was finally able to get it. I guess all the templates I had was implicitly defined.

Please Sign in or register to post replies

Write your reply to:

Draft