Copied to clipboard

Flag this post as spam?

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


  • mma 11 posts 100 karma points
    Mar 07, 2018 @ 09:28
    mma
    0

    Alternatives to a template

    From the Getting started tours and Umbraco TV's intoductory episodes I've got the knowledge, that a content node needs a document type for defining the structure of its content, and a template for displaying the content in the browser. OK, that's fine, I understand it. But yesterday I've installed the Articulate package and I see that it has created some content nodes, each having some document type, but lacking a template. How do they work? It seems to me that a template is only one possibility to define the layout of a content. What are the other alternatives and where can I learn them from?

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 07, 2018 @ 09:47
    Steve Morgan
    0

    Think of the document type as a blue print / content container. Some webpages might not just need their own content but might use content from a number of child pages.

    An example might be an About Us -> Our Staff page that lists staff members. You'd have a template called "Our Staff", with a corresponding content node that has the title and intro text etc. Underneath that content node you might have a number of StaffMember nodes. These are of doc type StaffMember but they don't need to have a Staff member template, instead their content is just looped through and output in the Our Staff page.

    The above example is trivial and might now be better served with Nested Content but I hope it makes sense. In other words there's not really an alternative to templates (*) but in some cases some doc types don't need a template.

      • I guess you could not use templates at all and just use Umbraco as a content holder via API Steve
  • mma 11 posts 100 karma points
    Mar 07, 2018 @ 10:57
    mma
    0

    Specifically, Articulate has created a tree with 3 content nodes , Blog, Archive and Authors. The latter 2 are the children of Blog. None of them have a template on its Info tab, however the Authors node doesn't show anything at all, except of an error message:

    An error occured
    
    
    
     Mapping types:
     Content -> IEnumerable`1
     Umbraco.Core.Models.Content -> System.Collections.Generic.IEnumerable`1[[Umbraco.Web.Models.ContentEditing.Tab`1[[Umbraco.Web.Models.ContentEditing.ContentPropertyDisplay, umbraco, Version=1.0.6631.28270, Culture=neutral, PublicKeyToken=null]], umbraco, Version=1.0.6631.28270, Culture=neutral, PublicKeyToken=null]]
    
     Destination path:
     ContentItemDisplay.Tabs.Tabs
    
     Source value:
     Umbraco.Core.Models.Content
    
    Exception Details
    AutoMapper.AutoMapperMappingException: 
    
     Mapping types:
     Content -> IEnumerable`1
     Umbraco.Core.Models.Content -> System.Collections.Generic.IEnumerable`1[[Umbraco.Web.Models.ContentEditing.Tab`1[[Umbraco.Web.Models.ContentEditing.ContentPropertyDisplay, umbraco, Version=1.0.6631.28270, Culture=neutral, PublicKeyToken=null]], umbraco, Version=1.0.6631.28270, Culture=neutral, PublicKeyToken=null]]
    
     Destination path:
     ContentItemDisplay.Tabs.Tabs
    
     Source value:
     Umbraco.Core.Models.Content
    

    Can it be that they (or at least one of them) do have a template only the aren't displayed on the Info tab due to some error? Do you mean that some of them surely must have a template?

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 07, 2018 @ 12:23
    Steve Morgan
    0

    Probably best to post this error to the Articulate forum - I'm not au fait with it I'm afraid.

  • mma 11 posts 100 karma points
    Mar 07, 2018 @ 12:37
    mma
    0

    Now I've made a brand new Umbraco installation without the example web site. Then I've installed the Articulate package. Now I don't have any template in the whole system at all, still the website works! And there is no error message anywhere, everything's fine. How is it possible?

    I think that this is an basic Umbreco question, not an Articulate specific one.

    Remark: While there are no templates (I've checked this, and found the cmsTemplate table really empty!), there are "Articulate themes" in the "Settings" section. It seems to me that they are alternatives to templates, that's why I asked for them.

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 07, 2018 @ 13:31
    Steve Morgan
    0

    Yes - sorry - rereading your original post you do mention Articulate. Apologies for missing that! I've just spun a fresh installation up to have a look.

    Have you seen the documentation? https://github.com/Shazwazza/Articulate/wiki

    The views are all stored in the themes folder under /App_Plugins/Articulate/Themes/Shazwazza/Views

    Custom Controllers are used which render the view in code. Here's a key example: https://github.com/Shazwazza/Articulate/blob/master/src/Articulate/Controllers/ArticulateController.cs

    HTH

    Steve

  • mma 11 posts 100 karma points
    Mar 07, 2018 @ 13:40
    mma
    0

    Thanks, Steve! Am I right, that one alternative of the templates are Custom Controllers? Or does this solution hack Umbraco?

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Mar 07, 2018 @ 13:45
    Steve Morgan
    1

    It's not a hack I suspect it's just using this: https://our.umbraco.org/documentation/reference/routing/custom-controllers

  • David Zweben 265 posts 749 karma points
    Mar 07, 2018 @ 13:51
    David Zweben
    1

    Understanding a bit about MVC will make this make more sense. Modern Umbraco is based off of .NET MVC. MVC is an 'architectural pattern' used to split up a site's code based on the type of task the code is responsible for, to make it cleaner. It's not an Umbraco-specific thing, but Umbraco uses it. The M, V, and C stand for Model, View, and Controller, respectively, and all 3 are used for building a web page.

    To give an [over]simplified summary, a controller should, ideally, run the code to access or generate the data used by the page, the model should take the data from the controller and wrap it up in a nice tidy package, and pass it to the View, which mixes it in with HTML and renders it. (Umbraco doesn't always follow this best practice, as it tends to encourage developers to put lots of code in the view, but that's a side-story.)

    Umbraco's 'templates' are really just Views. A view is needed to render a page, so there's no alternative to them, they may just be in a different spot than normal, or may be called a View rather than a template.

    Hope that helps clarify things.

    Regards,
    David

Please Sign in or register to post replies

Write your reply to:

Draft