Copied to clipboard

Flag this post as spam?

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


  • Profiterole 232 posts 264 karma points
    Apr 04, 2012 @ 16:01
    Profiterole
    0

    Change template for more than 1000 nodes

    Hi,

    I have more than 1000 nodes with the template "firstTemplate". But now, I'd like to change the template for another one "anotherTemplate". I changed the default template for the docyType and each new node as "anotherTemplate" as default template, but the existing ones are still publish with "firstTemplate".

    Do I have to manually change et save&publish each existing nodes to get them use "anotherTemplate"?

  • Mike Chambers 635 posts 1252 karma points c-trib
    Apr 04, 2012 @ 16:44
    Mike Chambers
    0

    you could create a dashboard, and do it programatically...

     Something like... with a couple of controls on the dashboard to pick the parent page of your nodes to update, and whether they should be published or not.

    Document doc = new Document(Convert.ToInt32(SimpleContentPicker1.Value));
    if (doc.HasChildren)
    {
        //you need to do this because doc.Children is an array. If you directly use it
        //in the foreach it'll execute the Array call each time (and it is a very
        //database heavy operation). Alternatively there is a AsList method which
        //is better too
    
        Document[] children = doc.Children;
        foreach (Document dChild in children)
        {
            d.Template = umbraco.cms.businesslogic.template.Template.GetTemplateIdFromAlias("YOURNEWTEMPLATE");
    
            d.Save();
    
            //if checked, publish document node 
            if (cbxPublish.Checked)
            {
    // if we were already publish publish us... if not don't
            if (d.Published)
            {
                //create/publish new version 
                d.Publish(umbraco.BusinessLogic.User.GetCurrent());
                //umbraco.library.PublishSingleNode(d.Id);
                umbraco.library.UpdateDocumentCache(d.Id);
            }
            else
            {
                d.Published = false;
                d.Save();
            }
    
            }
            else
            {
    //only save the changes
            d.Published = false;
            d.Save();
            }
        }
    }
  • Profiterole 232 posts 264 karma points
    Apr 04, 2012 @ 17:14
    Profiterole
    0

    Thank you, I'll try this. But I would have liked "built-in" solution!

  • Mike Chambers 635 posts 1252 karma points c-trib
    Apr 04, 2012 @ 17:21
    Mike Chambers
    0

    There are quite a few "omissions" in terms of bulk updates... you can't select to move files on mass... or delete selectively on mass... no inbuilt search and replace across your entire site...

    But the beauty of umbraco is that it's so easy to extend to whatever you want it to do ;-) in many other cms's you'd be stuck with no it doesn't do that...

  • Profiterole 232 posts 264 karma points
    Apr 04, 2012 @ 18:09
    Profiterole
    0

    Hi Mike, can you help me just a little more? So, I changed my dashboard file to include a new tab in developper section and it must call profiterole.ascx... but what should I do next? I never developped for Umbraco, in fact, I always relied on html only...

  • Profiterole 232 posts 264 karma points
    Apr 04, 2012 @ 18:23
    Profiterole
    0

    Hi Mike, finaly, I read a little about the subject and I will quit! It's too much for me. I'll think another way. But thank you!

  • Mike Chambers 635 posts 1252 karma points c-trib
    Apr 04, 2012 @ 18:25
    Mike Chambers
    0

    if I get chance... I'll put something together.. I think there is a quick solution to drop the cs file in the app_data folder, so that it compiles on the fly rather than having to install visual studio and all that understanding that entails..

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Apr 05, 2012 @ 08:56
    Richard Soeteman
    0

    @Mike you can mass delete using the Content maintenance dashboard package.http://our.umbraco.org/projects/developer-tools/content-maintenance-dashboard-package Other mass options will be added to the V5 version of the package.

     

  • Nigel 23 posts 78 karma points
    Feb 15, 2016 @ 08:45
    Nigel
    1

    Simple SQL for changing a template within a particular node.

    Update cmsDocument
    Set cmsDocument.templateId =  2687
    
    FROM            cmsContentXml INNER JOIN
                             cmsContent ON cmsContentXml.nodeId = cmsContent.nodeId INNER JOIN
                             cmsDocument ON cmsContent.nodeId = cmsDocument.nodeId
    WHERE        (cmsContentXml.xml LIKE '%path="-1,1537,2696,2754%')
    
    and cmsDocument.templateId = 2689
    
  • Richard Soeteman 4035 posts 12842 karma points MVP
    Feb 15, 2016 @ 10:39
    Richard Soeteman
    0

    Oh completely forgot to update this post. But Bulkmanager is released. Assign templates is one of the bulk actions.

    http://soetemansoftware.nl/bulkmanager

Please Sign in or register to post replies

Write your reply to:

Draft