Copied to clipboard

Flag this post as spam?

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


  • Thamodaran 5 posts 85 karma points
    Jun 20, 2023 @ 13:23
    Thamodaran
    0

    Replace the existing template to another template

    Hi , We are using Umbraco version 8.18.5 . I need to replace the current template of the content to another template .

    Is there any way to achieve this through any package or programmatically ?

    Since our site contains more than 20 contents node, it takes more time to do it by manually .

    Expected scenario : If the content "Test" contains "SampleMacro" then we need to update the template of this content into another template .

  • Simon Napper 84 posts 254 karma points
    Jun 20, 2023 @ 19:52
    Simon Napper
    100

    Hi Thamodaran,

    If memory serves then probably the best way to go about this is to use the ContentService to retrieve your content. If your template has already been created, then you should be able to use the FileService and

    GetTemplate("TemplateIdHere");
    

    to retrieve the template and from there you can get the template Id and set it on your content via the TemplateId property.

    Don't forget to either save or publish via the ContentService it for the changes to take affect!

Please Sign in or register to post replies

Write your reply to:

Draft