Copied to clipboard

Flag this post as spam?

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


  • Ernst Utvik 123 posts 235 karma points
    Aug 05, 2010 @ 12:40
    Ernst Utvik
    0

    Change document name from usercontrol?

    Hi

    I made a usercontrol for creating and editing forumposts. My question is: when editing a previously created post (node) is it possible to change the name of the node also? I use the node name in the post headings, so if I cant change this I will have to make e new "heading" property.

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 05, 2010 @ 13:24
    Thomas Höhler
    0

    You can:

    document = new umbraco.cms.businesslogic.web.Document(YOURDOCUMENTID);
    document.Text = "YOUR NEW NODE NAME";
    document.Publish(new User(0));
    umbraco.library.UpdateDocumentCache(document.Id);

    hth, Thomas

  • Bogdan 250 posts 427 karma points
    Aug 05, 2010 @ 13:24
    Bogdan
    0

    Yes, the Text property of a Document is the node's name, and you can change it from the user control: doc.Text = "some new node name"; I'm not very sure, but you can give it a try.

  • Sascha Wolter 615 posts 1101 karma points
    Aug 05, 2010 @ 13:29
    Sascha Wolter
    0

    Hi Ernst,

    it is possible to change the name of a node in .Net, e.g.

    Document doc = new Document(123123);
    doc.Text = "new node name";
    //followed by saving/publishing the document and updating the cache

    However I would still tend to create a separate field for the heading for 2 reasons: when you change the name of the node you also change it's url and you might end up with some long text containing maybe some odd special characters, and although the CMS will be able to work with all this it's probably not the nicest way to implement things.

    Hope that helps,
    Sascha

     

  • Ernst Utvik 123 posts 235 karma points
    Aug 05, 2010 @ 13:54
    Ernst Utvik
    0

    And that solved it :)

    Thank you!

    You learn a little every day.

Please Sign in or register to post replies

Write your reply to:

Draft