Copied to clipboard

Flag this post as spam?

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


  • Ben 112 posts 398 karma points
    Jun 01, 2017 @ 18:46
    Ben
    0

    Apply new site wide default template

    Hi all,

    I am currently working on converting my WebForms site to MVC in Umbraco v7.6.2. I have been able to re-create the WebForms templates as separate MVC templates and that has worked well for individual pages. Without touching each individual page, is there a way to update all pages to use a new default template?

    Here is what I have tried:

    1. Set the default template for the Document Types to the new MVC template
    2. Delete the old WebForms templates from the Document Types
    3. Republish entire site

    This made the template field for the Content document blank.

  • Philb1208 18 posts 102 karma points
    Jun 05, 2017 @ 16:21
    Philb1208
    0

    I'm not sure if this helps.

    https://our.umbraco.org/documentation/tutorials/creating-basic-site/creating-master-template-part-1

    I dont know what the difference is but we use a sitewide master template and a homepage template.

  • Ben 112 posts 398 karma points
    Jun 05, 2017 @ 17:23
    Ben
    0

    Thanks for the response, but that is not quite what I am looking for, and I apologize ahead for the longer post.

    I currently have templates (site wide master and homepage/sub page) that were created when the site was set to WebForms (umbracoSettings.config <defaultRenderingEngine>WebForms</defaultRenderingEngine>). All of our documents are currently using those templates. I want to upgrade our site to Umbraco v7.6.2 and change the templates to be MVC templates (Layout/partial views).

    I was able to re-create the current WebForms templates using MVC in the Templates section of the settings area and I now want to use the new MVC templates instead of the old WebForms templates. To do this, it looks like I need to open each page, click on the Properties tab, go down and change the template to the new template.

    What I am wondering is if there is an automated way to change all the pages using a certain template to use a different template?

    I tried what I mentioned in the first post as well as the following:

    1. Go into the database for Umbraco
    2. Open cmsContentXml and filter for a specific page
    3. Update the xml field by changing where it says template="1115" to the id of my new template (ex: template="2946"). This id can be found in cmsTemplate
    4. Update the cmsPreviewXml for the current version (found in cmsContentVersion for the ContentID/nodeid of the page updated in step 3)

    However, nothing changes and if you go into the Properties tab it shows a blank for the template and I still have to select the new MVC one from the drop down and click the Save and Publish button.

    I noticed that the logs show that the content xml is written to a file, but the logs don't mention where that file is.

    One of my sites has a few hundred pages and it would take a long time to update each page individually to use the new template.

  • Amir Khan 1287 posts 2744 karma points
    Jun 05, 2017 @ 17:37
    Amir Khan
    100

    Might be worth taking a look at Richard's plugin, it isn't free but it works and he's very responsive if you run into any issues: https://soetemansoftware.nl/bulkmanager

    You could also do it programmatically using the content service API.

    -Amir

  • Ben 112 posts 398 karma points
    Jun 05, 2017 @ 17:44
    Ben
    0

    Thanks Amir! I will check out both of those options.

  • Sotiris Filippidis 286 posts 1501 karma points
    Oct 27, 2017 @ 15:50
    Sotiris Filippidis
    2

    I'm a little late in this topic :) but still I'm mentioning this since it could be useful - I've put together some code that you can put on your app_code folder and on next application startup it will look for documents that don't have a template and update them with their default template (provided a default template has been defined for their doctype). It's an one-time thing, so then you can remove it.

    It works only if documents don't have any template, which I fear is not your case, but I'm mentioning it here in case somebody else has a similar issue. It's saved me from having to manually update dozens of nodes a couple of times.

    Here's the post with the code: http://www.dot-see.com/en/blog/bulk-updating-document-types-with-their-default-templates/

  • Ben 112 posts 398 karma points
    Oct 27, 2017 @ 16:20
    Ben
    0

    Thanks Sortiris. I ended up making my own custom plugin that let's me select one template and change all documents that use that template to another template that I select. If anyone is interested I can post the code here.

Please Sign in or register to post replies

Write your reply to:

Draft