Copied to clipboard

Flag this post as spam?

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


  • TJ 2 posts 92 karma points
    Dec 07, 2022 @ 11:36
    TJ
    0

    Reskin - Implement a new version of Templates whilst keeping old existing in place for pages untouched

    Hi,

    I have been tasked with implementing a new set of designs for an Umbraco 8 website. I'm new specifically to Umbraco and come from more of a frontend background.

    Would like to leave the pages using the old existing templates but implement a new V2 for example. This would allow me to change the template over one at a time for each page as I work through. Therefore leaving a fully working version in place for the untouched pages using the old version with no broken features.

    I tried simply carrying out what I thought would be the correct steps below but get the following error.

    Server Error in '/' Application. Cannot bind source content type XYZ.UmbracoDocTypeModels.PageName to model type XYZ.Common.ViewModels.PageNameViewModel.

    Created as an example the following under Settings > Templates:

    PageNameTemplate.cshtml (original) PageNameTemplateV2.cshtml (new) [copied source from original to keep simple for now]

    Under Document Types > RootDocType > TemplatePage:

    Added the PageNameTemplateV2 to the Allowed Templates.

    Made a small comment non breaking change to the source for PageNameTemplateV2.cshtml to output in HTML .

    Under Content I chose MyWorkingPage and changed the template from PageNameTemplate to PageNameTemplateV2.

        @inherits Umbraco.Web.Mvc.UmbracoViewPage<PageNameViewModel>
    @{
        Layout = "PageNameTemplateV2.cshtml";
    
            var pageName = Model.UmbracoModel as XYZ.UmbracoDocTypeModels.PageName;
    
    }
    <!--TESTING-->
    

    Umbraco seems to want to force the Model Name to match which does not for V2.

    Is there are way I can work around this or am I trying to go about this right way and there is another recommended method?

    Many thanks.

  • TJ 2 posts 92 karma points
    Dec 07, 2022 @ 12:39
    TJ
    100

    I think I might be onto something as I have it working but with duplicated code.

    I am hijacking within the controller but essentially I have had to duplicate the existing extensive code from the existing ActionResult into the new one which seems a bit bloated.

    But the item which helped me get to here is:

    https://our.umbraco.com/documentation/reference/routing/custom-controllers/

    Still would like to know if I am going about this the correct way or if there is a much simpler way to have 2 templates for the reskin. The bloated code seems a bit smelly to me.

    Many thanks.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies